Class: ATDIS::Validators::GeoJsonValidator

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



6
7
8
9
10
11
12
13
# File 'lib/atdis/validators.rb', line 6

def validate_each(record, attribute, value)
  raw_value = record.send("#{attribute}_before_type_cast")
  if raw_value.present? && value.nil?
    message = "is not valid GeoJSON"
    message = ErrorMessage[message, options[:spec_section]] if options[:spec_section]
    record.errors.add(attribute, message)
  end
end