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



39
40
41
42
43
44
45
46
47
# File 'lib/atdis/validators.rb', line 39

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