Sha256: 0a8755acac1f0de2d95239ff0d4254235df4c6ed91dce02fae01847a56583aef

Contents?: true

Size: 255 Bytes

Versions: 5

Compression:

Stored size: 255 Bytes

Contents

class BooleanValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    unless [true, false, 1, 0].include?(value)
      record.errors[attribute] << (options[:message] || I18n.t('errors.messages.boolean'))
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flash_validators-3.0.1 lib/flash_validators/validators/boolean_validator.rb
flash_validators-3.0.0 lib/flash_validators/validators/boolean_validator.rb
flash_validators-1.1.0 lib/flash_validators/validators/boolean_validator.rb
flash_validators-1.0.0 lib/flash_validators/validators/boolean_validator.rb
flash_validators-0.0.1 lib/flash_validators/validators/boolean_validator.rb