class UrlValidator
global namespace so you can use the rails 3 “validate :field, email: [options]”
Public Instance Methods
validate_each(record,attribute,value)
click to toggle source
# File lib/url_attribute/url_validator.rb, line 3 def validate_each(record,attribute,value) return if value.blank? && options[:allow_blank] case value when UrlAttribute::Url record.errors.add(attribute, options.fetch(:message, :invalid)) unless value.valid? when String record.errors.add(attribute, options.fetch(:message, :invalid)) unless UrlAttribute::Url.load(value).valid? end end