Skip to content

Commit

Permalink
chore(ajv): Change reducer fn name and signature
Browse files Browse the repository at this point in the history
  • Loading branch information
ktunador committed Dec 10, 2024
1 parent c4e65e2 commit 61d320c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ajv/src/ajv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ const parseErrorSchema = (
) => {
const parsedErrors: Record<string, FieldError> = {};

const parseAndSaveError = (
error: AjvError,
parsedErrors: Record<string, FieldError>,
) => {
const reduceError = (error: AjvError) => {
// Ajv will return empty instancePath when require error
if (error.keyword === 'required') {
error.instancePath += `/${error.params.missingProperty}`;
Expand Down Expand Up @@ -51,10 +48,10 @@ const parseErrorSchema = (
if (error.keyword === 'errorMessage') {
error.params.errors.forEach((originalError) => {
originalError.message = error.message;
parseAndSaveError(originalError, parsedErrors);
reduceError(originalError);
});
} else {
parseAndSaveError(error, parsedErrors);
reduceError(error);
}
}

Expand Down

0 comments on commit 61d320c

Please sign in to comment.