You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def flatten_outcome_errors(nested_errors, memo_path = [], memo_flat_errors = [])
return if nested_errors.nil? # can happen in arrays
nested_errors.each_with_object(memo_flat_errors) do |(key, value), memo|
path = memo_path + [key]
case value
when Array
value.each_with_index do |val, index|
path = memo_path + ["#{key}[#{index}]"]
flatten_outcome_errors(val, path, memo)
end
when Hash
flatten_outcome_errors(value, path, memo)
when Mutations::ErrorAtom
memo << export_mutation_error(value, path)
else
# is it even possible ?
end
end
end
def export_mutation_error(e, path)
# e.instance_variable_get(:@key) already included in path
{
key: path.join('.'),
symbol: e.instance_variable_get(:@symbol),
message: e.instance_variable_get(:@message)
}
end
is there a method to get all the errors in an array ? (even if they are nested)
when validating a hash for instance :
The text was updated successfully, but these errors were encountered: