Skip to content

Add url format validator#1

Open
uragap wants to merge 8 commits into
masterfrom
dev
Open

Add url format validator#1
uragap wants to merge 8 commits into
masterfrom
dev

Conversation

@uragap
Copy link
Copy Markdown
Owner

@uragap uragap commented Jan 10, 2022

No description provided.

Comment thread README.md
Comment thread lib/validates_url_format/validator.rb Outdated
Comment thread lib/validates_url_format/validator.rb Outdated
Comment thread lib/validates_url_format/validator.rb
Comment thread README.md Outdated
Comment thread lib/validates_url_format/validator.rb Outdated
Comment thread lib/validates_url_format/validator.rb Outdated
Comment thread lib/validates_url_format/validator.rb
Comment thread README.md Outdated
Comment thread lib/validates_url_format/version.rb Outdated
@@ -0,0 +1,3 @@
module ValidatesUrlFormat
VERSION = '0.0.1'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VERSION = '0.0.1'
VERSION = '0.1.0'

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread lib/validates_url_format.rb Outdated
DEFAULT_SCHEMES = %w(http https)

def initialize(options)
options.reverse_merge!(messages: DEFAULT_MESSAGES, no_local: false, public_suffix: false)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class Model < OpenStruct
   include ActiveModel::Validations
   validates_url_format_of :url, allow_blank: false, allow_nil: true, no_local: true, messages: { invalid_url: 'ABOBA'}
end

options.reverse_merge!(messages: DEFAULT_MESSAGES, no_local: false, public_suffix: false)
=> {:messages=>{:invalid_url=>"ABOBA"}, :no_local=>true, :public_suffix=>false, :allow_blank=>false, :allow_nil=>true, :attributes=>[:url], :class=>Model}

messages как-то смерджились не так

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants