Sha256: 8990c89555dcbef8ce8847736a0d1f7ad880ca5d5c9511d605be97146ff5ee1d
Contents?: true
Size: 462 Bytes
Versions: 4
Compression:
Stored size: 462 Bytes
Contents
class BooleanValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless TRUE_VALUES.include?(value) || FALSE_VALUES.include?(value) record.errors[attribute] << (options.fetch(:message, false) || I18n.t('active_validation.errors.messages.boolean'.freeze)) end end private FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].freeze TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze end
Version data entries
4 entries across 4 versions & 1 rubygems