Sha256: 39b0efbcf959d1256e1f954032448ceacd86708138cb1181aec0ac02cbbb8658
Contents?: true
Size: 515 Bytes
Versions: 2
Compression:
Stored size: 515 Bytes
Contents
# frozen_string_literal: true class TimeZoneValidator < ActiveModel::EachValidator 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 def valid_time_zone?(value) ActiveSupport::TimeZone[value].present? end def valid_length?(value) value.present? end def valid?(value) valid_length?(value) && valid_time_zone?(value) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_validation-5.0.0 | lib/active_validation/validators/time_zone_validator.rb |
active_validation-4.1.0 | lib/active_validation/validators/time_zone_validator.rb |