Class: TimeZoneValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- TimeZoneValidator
- 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, [:message] || :invalid_time_zone) unless ActiveSupport::TimeZone[value] end |