Sha256: 3da874d378654800b78b20670a6fcdad4f498399c8307bb131dff418156e3eb1

Contents?: true

Size: 403 Bytes

Versions: 4

Compression:

Stored size: 403 Bytes

Contents

class HashValidator::Validator::BooleanValidator < HashValidator::Validator::Base
  def initialize
    super('boolean')  # The name of the validator
  end

  def validate(key, value, _validations, errors)
    unless [TrueClass, FalseClass].include?(value.class)
      errors[key] = presence_error_message
    end
  end
end

HashValidator.append_validator(HashValidator::Validator::BooleanValidator.new)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hash_validator-1.1.1 lib/hash_validator/validators/boolean_validator.rb
hash_validator-1.1.0 lib/hash_validator/validators/boolean_validator.rb
hash_validator-1.0.0 lib/hash_validator/validators/boolean_validator.rb
hash_validator-0.8.0 lib/hash_validator/validators/boolean_validator.rb