Class: ATDIS::Validators::ArrayHttpUrlValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/atdis/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/atdis/validators.rb', line 37

def validate_each(record, attribute, value)
  if value.present? && value.kind_of?(Array) &&
    value.any?{|v| !v.kind_of?(URI::HTTP) && !v.kind_of?(URI::HTTPS)}
      message = "contains an invalid URL"
      message = ErrorMessage[message, options[:spec_section]] if options[:spec_section]
      record.errors.add(attribute, message)
  end
end