Class: TimeZoneValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/time_zone_validator.rb

Overview

This validator ensures timezones are valid. This is, supported by ActiveSupport::TimeZone

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
9
# File 'app/validators/time_zone_validator.rb', line 5

def validate_each(record, attribute, value)
  return if value.blank?

  record.errors.add(attribute, options[:message] || :invalid_time_zone) unless ActiveSupport::TimeZone[value]
end