Sha256: ef6331ed6d46e3b7f927bfe84dc736b4b8a37b9a3b3ec65bde34bf794aafe07d
Contents?: true
Size: 466 Bytes
Versions: 2
Compression:
Stored size: 466 Bytes
Contents
# frozen_string_literal: true class BooleanValidator < ActiveModel::EachValidator FALSE_VALUES ||= [false, 0, '0', 'f', 'F', 'false', 'FALSE'].freeze TRUE_VALUES ||= [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze def validate_each(record, attribute, value) return if TRUE_VALUES.include?(value) || FALSE_VALUES.include?(value) record.errors[attribute] << (options[:message] || I18n.t('active_validation.errors.messages.boolean')) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_validation-5.0.0 | lib/active_validation/validators/boolean_validator.rb |
active_validation-4.1.0 | lib/active_validation/validators/boolean_validator.rb |