Class: TimezoneField::ZoneValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



8
9
10
11
12
13
# File 'lib/timezone_field.rb', line 8

def validate_each(record, attribute, value)
  value = record.send(:read_attribute, attribute)
  if value.present?
    record.errors[attribute] << 'Unrecognized timezone' if ActiveSupport::TimeZone[value].nil?
  end
end