Compare commits

..

No commits in common. 'master' and 'master' have entirely different histories.

@ -2,6 +2,8 @@
// TODO: Rename this to something more appropriate, like any/anyOf? How to make sure that doesn't cause confusion with `oneOf`?
const flatten = require("flatten");
const ValidationError = require("@validatem/error");
const combinator = require("@validatem/combinator");
const validationResult = require("@validatem/validation-result");
@ -12,13 +14,13 @@ const areErrorsFromSameOrigin = require("./src/are-errors-from-same-origin");
function unpackNestedEithers(errors) {
// NOTE: We only unpack `either` errors that occurred *at the same level* as this error, ie. where there's directly a case of `either(either(...), ...)`, without any kind of data nesting (like `arrayOf` or `hasShape`) inbetween. Nested-data failures should still be shown separately, as their resolution strategy is actually different; unlike same-level nested `either` errors, where the nesting is purely an implementation detail that allows composing sets of alternatives together.
return (errors.map((error) => {
return flatten(errors.map((error) => {
if (error.path.length === 0 && error.__isValidatemEitherError) {
return error.subErrors;
} else {
return error;
}
})).flat(Infinity);
}));
}
function hasNestedPaths(error) {

@ -20,6 +20,7 @@
"@validatem/combinator": "^0.1.1",
"@validatem/error": "^1.0.0",
"@validatem/match-validation-error": "^0.1.0",
"@validatem/validation-result": "^0.1.2"
"@validatem/validation-result": "^0.1.2",
"flatten": "^1.0.3"
}
}

Loading…
Cancel
Save