Class: Perfectline::ValidatesUrl::Rails3::UrlValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Perfectline::ValidatesUrl::Rails3::UrlValidator
- Defined in:
- lib/validates_url.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ UrlValidator
constructor
A new instance of UrlValidator.
- #validate_each(record, attribute, value) ⇒ Object
Constructor Details
#initialize(options) ⇒ UrlValidator
Returns a new instance of UrlValidator.
53 54 55 56 57 |
# File 'lib/validates_url.rb', line 53 def initialize() .reverse_merge!(:schemes => %w(http https)) .reverse_merge!(:message => "is not a valid URL") super() end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
59 60 61 62 63 |
# File 'lib/validates_url.rb', line 59 def validate_each(record, attribute, value) unless Perfectline::ValidatesUrl::Validator.valid_url?(value, .fetch(:schemes)) record.errors.add(attribute, .fetch(:message), :value => value) end end |