Sha256: 9c9d698abb610b79dc5036384329bbe314221946409c4b991c5470ae8f2c95bf
Contents?: true
Size: 752 Bytes
Versions: 4
Compression:
Stored size: 752 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) unless value.nil? ::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
4 entries across 4 versions & 1 rubygems