Skip to content

Commit

Permalink
fix: Validators error messages not showing properly
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik committed Sep 20, 2024
1 parent 744fabe commit 784b91e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ export class BaseReview {
let field: string;

return errors.reduce((obj, error) => {
if (error.keyword === 'required') field = error.params.missingProperty;
else [, field] = error.instancePath.split('/');

field = field.replace(/~1/g, '/');
if (!!uniqueCombinations[error.keyword]) {
uniqueCombinations[error.keyword].forEach((columnKey) => {
obj[columnKey] = this.getMessage({
Expand All @@ -208,7 +204,11 @@ export class BaseReview {
validatorErrorMessages,
});
});
} else
} else {
if (error.keyword === 'required') field = error.params.missingProperty;
else [, , field] = error.instancePath.split('/');

field = field.replace(/~1/g, '/');
obj[field] = this.getMessage({
error,
data: error.data,
Expand All @@ -217,6 +217,7 @@ export class BaseReview {
uniqueCombinations,
validatorErrorMessages,
});
}

return obj;
}, {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DoReReview extends BaseReview {
});

const columns = JSON.parse(uploadInfo.customSchema) as ITemplateSchemaItem[];
const uniqueFieldsSet = new Set(...columns.filter((column) => column.isUnique).map((column) => column.key));
const uniqueFieldsSet = new Set(columns.filter((column) => column.isUnique).map((column) => column.key));
const multiSelectColumnHeadings: Record<string, string> = {};
const validatorErrorMessages = {};
(columns as ITemplateSchemaItem[]).forEach((column) => {
Expand Down Expand Up @@ -205,6 +205,7 @@ export class DoReReview extends BaseReview {
validator,
dateFormats,
uniqueCombinations,
validatorErrorMessages,
multiSelectColumnHeadings,
}: {
uploadId: string;
Expand All @@ -231,6 +232,7 @@ export class DoReReview extends BaseReview {
dateFormats,
uniqueCombinations,
index: record.index,
validatorErrorMessages,
passRecord: record.record,
});
response.totalRecords++;
Expand Down

0 comments on commit 784b91e

Please sign in to comment.