Sha256: 938903238507cd948492450cf8cd8caeed52407136a05bbcc05ad3f0883671f3
Contents?: true
Size: 572 Bytes
Versions: 1
Compression:
Stored size: 572 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 presence_error_message 'value from list required' 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hash_validator-1.0.0 | lib/hash_validator/validators/class_validator.rb |