Sha256: 8083b148b5ae120dd06a337c31e90cb0ec141be24ed3a1e2273feeee783f9570
Contents?: true
Size: 787 Bytes
Versions: 2
Compression:
Stored size: 787 Bytes
Contents
module NxtSchema module Validators class OptionalNode < Validator def initialize(conditional, missing_key) @conditional = conditional @missing_key = missing_key end register_as :optional_node attr_reader :conditional, :missing_key def build lambda do |application, value| args = [application, value] return if conditional.call(*args.take(conditional.arity)) return if application.send(:keys).include?(missing_key.to_sym) message = ErrorMessages.resolve( application.locale, :required_key_missing, key: missing_key, target: application.input ) application.add_error(message) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nxt_schema-1.0.1 | lib/nxt_schema/validators/optional_node.rb |
nxt_schema-1.0.0 | lib/nxt_schema/validators/optional_node.rb |