Skip to content

Commit

Permalink
handle only $schema related errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Puczynski committed Feb 26, 2019
1 parent 7469b1a commit 2e5d5b9
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,38 @@ export default function validateFormData(
// Clear errors to prevent persistent errors, see #1104

ajv.errors = null;
if (validationError && validationError.message) {

const noProperMetaSchema =
validationError &&
validationError.message &&
typeof validationError.message === "string" &&
validationError.message.includes("no schema with key or ref ");

if (noProperMetaSchema) {
errors = [
...errors,
{
stack: validationError.message,
},
];
}

if (typeof transformErrors === "function") {
errors = transformErrors(errors);
}
const errorSchema = toErrorSchema(errors);

let errorSchema = toErrorSchema(errors);

if (noProperMetaSchema) {
errorSchema = {
...errorSchema,
...{
$schema: {
__errors: [validationError.message],
},
},
};
}

if (typeof customValidate !== "function") {
return { errors, errorSchema };
}
Expand Down

0 comments on commit 2e5d5b9

Please sign in to comment.