Module: Lite::Validation::Validator::Coordinator::Errors::Hierarchical
- Defined in:
- lib/lite/validation/validator/coordinator/errors/hierarchical.rb
Class Method Summary collapse
Class Method Details
.build(result) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lite/validation/validator/coordinator/errors/hierarchical.rb', line 9 def self.build(result) root_errors = result.send(:errors_root) children = result.send(:children).each_with_object({}) do |(key, child), acc| child_errors = build(child) acc[key] = child_errors unless child_errors.empty? end if children.empty? { errors: root_errors } elsif root_errors.empty? { children: children } else { errors: root_errors, children: children } end end |