Sha256: 432eb4a639d71dab071de502a13f51f7108f674861b14bda336bfa1f1518c426

Contents?: true

Size: 610 Bytes

Versions: 13

Compression:

Stored size: 610 Bytes

Contents

class HashValidator::Validator::EnumerableValidator < HashValidator::Validator::Base
  def initialize
    super('_enumerable')  # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator)
  end

  def should_validate?(rhs)
    rhs.is_a?(Enumerable)
  end

  def presence_error_message
    'value from list required'
  end

  def validate(key, value, validations, errors)
    unless validations.include?(value)
      errors[key] = presence_error_message
    end
  end
end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hash_validator-1.1.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-1.0.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.8.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.7.1 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.7.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.6.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.5.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.4.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.3.0 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.2.7 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.2.6 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.2.5 lib/hash_validator/validators/enumerable_validator.rb
hash_validator-0.2.4 lib/hash_validator/validators/enumerable_validator.rb