Sha256: 00b03970d3b6a98ba503f91f96b1f698d4cf9c283170ffbbcaf3ec98d029f020
Contents?: true
Size: 743 Bytes
Versions: 5
Compression:
Stored size: 743 Bytes
Contents
module HashValidator module Validator class OptionalValidator < Base def initialize super('_optional') # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(validation) validation.is_a?(Validations::Optional) end def validate(key, value, validations, errors) if value ::HashValidator.validator_for(validations.validation).validate(key, value, validations.validation, errors) errors.delete(key) if errors[key].respond_to?(:empty?) && errors[key].empty? end end end end end HashValidator.append_validator(HashValidator::Validator::OptionalValidator.new)
Version data entries
5 entries across 5 versions & 1 rubygems