Sha256: 369f2fb6162dc5967fdc1c351263a4d19b02cf935c25c28aae2a5b45085d23f8
Contents?: true
Size: 850 Bytes
Versions: 15
Compression:
Stored size: 850 Bytes
Contents
module Datacaster class AndWithErrorAggregationNode < Base def initialize(left, right) @left = left @right = right end # Works like AndNode, but doesn't stop at first error — in order to aggregate all Failures # Makes sense only for Hash Schemas def cast(object, runtime:) left_result = @left.with_runtime(runtime).(object) if left_result.valid? @right.with_runtime(runtime).(left_result.value) else right_result = @right.with_runtime(runtime).(object) if right_result.valid? left_result else Datacaster.ErrorResult(Utils.merge_errors(left_result.raw_errors, right_result.raw_errors)) end end end def inspect "#<Datacaster::AndWithErrorAggregationNode L: #{@left.inspect} R: #{@right.inspect}>" end end end
Version data entries
15 entries across 15 versions & 1 rubygems