Sha256: 10c8dbc3a461d0eb100631626f32ddbb12b33b881994aad8b316182383ec17b9
Contents?: true
Size: 435 Bytes
Versions: 1
Compression:
Stored size: 435 Bytes
Contents
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_validation-4.0.11 | lib/active_validation/validators/boolean_validator.rb |