class TimeZoneValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/active_validation/validators/time_zone_validator.rb, line 5
def validate_each(record, attribute, value)
  return if valid?(value)

  record.errors[attribute] <<
    (options[:message] || I18n.t('active_validation.errors.messages.time_zone'))
end

Private Instance Methods

valid?(value) click to toggle source
# File lib/active_validation/validators/time_zone_validator.rb, line 22
def valid?(value)
  valid_length?(value) &&
    valid_time_zone?(value)
end
valid_length?(value) click to toggle source
# File lib/active_validation/validators/time_zone_validator.rb, line 18
def valid_length?(value)
  value.present?
end
valid_time_zone?(value) click to toggle source
# File lib/active_validation/validators/time_zone_validator.rb, line 14
def valid_time_zone?(value)
  ActiveSupport::TimeZone[value].present?
end