Class: TimeZoneValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- TimeZoneValidator
- Defined in:
- lib/autoload/time_zone_validator.rb
Instance Method Summary collapse
-
#validate(record) ⇒ Object
Custom time_zone validation as +#time_zone+ getter has been modified.
Instance Method Details
#validate(record) ⇒ Object
Custom time_zone validation as +#time_zone+ getter has been modified.
Possible time_zones include +nil+ or those listed in ActiveSupport::TimeZone
6 7 8 9 10 11 |
# File 'lib/autoload/time_zone_validator.rb', line 6 def validate(record) return if record[:time_zone].nil? || ActiveSupport::TimeZone[record[:time_zone]].present? record.errors.add(:time_zone, I18n.t('activerecord.errors.messages.time_zone_validator.invalid_time_zone')) end |