Class: ActiveModel::Validations::UrlValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::UrlValidator
- Defined in:
- lib/active_model/validations/url_validator.rb
Overview
Validates that the value is a url
Example:
validates :website_url, url: true
Constant Summary collapse
- URL_PATTERN =
URI::DEFAULT_PARSER.make_regexp(%w[http https]).freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
14 15 16 |
# File 'lib/active_model/validations/url_validator.rb', line 14 def attribute @attribute end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
14 15 16 |
# File 'lib/active_model/validations/url_validator.rb', line 14 def record @record end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
14 15 16 |
# File 'lib/active_model/validations/url_validator.rb', line 14 def value @value end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_model/validations/url_validator.rb', line 16 def validate_each(record, attribute, value) @record = record @attribute = attribute @value = value return if skip? return unless validate_url nil unless maybe_validate_image_url end |