Sha256: 6c2cca9edd8e298a4e4f3bdb3ab07c131f10b2f926111333d0cbe5ed885e5dfe
Contents?: true
Size: 505 Bytes
Versions: 2
Compression:
Stored size: 505 Bytes
Contents
class HashValidator::Validator::ClassValidator < HashValidator::Validator::Base def initialize super('_class') # 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?(Class) end def validate(key, value, klass, errors) unless value.is_a?(klass) errors[key] = "#{klass} required" end end end HashValidator.append_validator(HashValidator::Validator::ClassValidator.new)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hash_validator-1.1.1 | lib/hash_validator/validators/class_validator.rb |
hash_validator-1.1.0 | lib/hash_validator/validators/class_validator.rb |