diff --git a/src/routes/index.js b/src/routes/index.js index 30de34e7..4887163f 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -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); + }), }); } diff --git a/src/validations/labels.validations.js b/src/validations/labels.validations.js index 915d72b9..5b7604aa 100644 --- a/src/validations/labels.validations.js +++ b/src/validations/labels.validations.js @@ -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(), };