Class: Rearview::Configuration::UrlValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Rearview::Configuration::UrlValidator
- Defined in:
- lib/rearview/configuration.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rearview/configuration.rb', line 10 def validate_each(record, attribute, value) passed = true if value.present? uri = URI.parse(value) rescue nil unless uri.present? && uri.scheme.present? && (uri.scheme.downcase=="http" || uri.scheme.downcase=="https") record.errors.add attribute, ([:message] || "is not a valid URL") passed = false end end passed end |