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