Class: UrlValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- UrlValidator
- Defined in:
- lib/flash_validators/validators/url_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/flash_validators/validators/url_validator.rb', line 4 def validate_each(record, attribute, value) uri = URI.parse(value) raise URI::InvalidURIError unless valid?(uri, ) rescue URI::InvalidURIError record.errors[attribute] << ([:message] || I18n.t('flash_validators.errors.messages.url')) end |