Class: Typed::Validations::ValidationResults
- Extended by:
- T::Sig
- Defined in:
- lib/typed/validations/validation_results.rb
Instance Method Summary collapse
Methods inherited from T::Struct
deserialize_from, schema, #serialize_to, serializer
Instance Method Details
#combine ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/typed/validations/validation_results.rb', line 11 def combine failing_results = results.select(&:failure?) case failing_results.length when 0 Success.new( results.each_with_object({}) do |result, validated_params| validated_params[result.payload.name] = result.payload.value end ) when 1 Failure.new(T.must(failing_results.first).error) else Failure.new(MultipleValidationError.new(errors: failing_results.map(&:error))) end end |