Skip to content

Commit

Permalink
fix: error message
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Jan 27, 2022
1 parent 3997652 commit 5a45a35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ app.use((err, req, res, next) => {
// format Joi validation errors
return res.status(400).json({
message: 'API Validation error',
errors: err.error.details.map((detail) => detail.message),
errors: err.error.details.map((detail) => {
console.log(detail);
return _.get(detail, 'context.message', detail.message);
}),
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/validations/labels.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Joi from 'joi';

const baseSchema = {
label: Joi.string().required(),
creditingPeriodStartDate: Joi.date().required(),
creditingPeriodEndDate: Joi.date().required(),
validityStartDate: Joi.date().required(),
validityPeriodEndDate: Joi.date().required(),
creditingPeriodStartDate: Joi.string().required(),
creditingPeriodEndDate: Joi.string().required(),
validityPeriodStartDate: Joi.string().required(),
validityPeriodEndDate: Joi.string().required(),
unitQuantity: Joi.number().integer().required(),
labelLink: Joi.string().required(),
};
Expand Down

0 comments on commit 5a45a35

Please sign in to comment.