Sha256: 25855456272f436740decbb370f6f92e07b7d9a232b4a304ce25a362ccd0e5bf
Contents?: true
Size: 776 Bytes
Versions: 3
Compression:
Stored size: 776 Bytes
Contents
module NxtSchema module Node class ValidateWithProxy def initialize(node) @node = node @aggregated_errors = [] end attr_reader :node delegate_missing_to :node def validate(&block) result = instance_exec(&block) return if result copy_aggregated_errors_to_node end def add_error(error) aggregated_errors << error false end def copy_aggregated_errors_to_node aggregated_errors.each do |error| node.add_error(error) end end private attr_reader :aggregated_errors def validator(key, *args) validator = node.validator(key, *args) validator.call(self, node.value) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nxt_schema-0.1.2 | lib/nxt_schema/node/validate_with_proxy.rb |
nxt_schema-0.1.1 | lib/nxt_schema/node/validate_with_proxy.rb |
nxt_schema-0.1.0 | lib/nxt_schema/node/validate_with_proxy.rb |