arb / celebrate

A joi validation middleware for Express.
MIT License
1.33k stars 66 forks source link

Celebrate v13 not able to validate Array which is coming from query. #208

Closed airrakeshkumarsharma closed 3 years ago

airrakeshkumarsharma commented 3 years ago

My joi schema looks like this: `Joi.object().keys({ // Filters filters: Joi.array() .items({ key: Joi.string().required(), type: Joi.string(), value: [Joi.string().trim(), Joi.array(), Joi.boolean()], upperValue: [Joi.number(), Joi.string().isoDate().allow(null)], lowerValue: [Joi.number(), Joi.string().isoDate().allow(null)], operation: Joi.string() }) .default([]),

// Sort sort: Joi.array() .items({ key: Joi.string().required(), order: Joi.number().required() }) .default([]),

// Pagination perPage: Joi.number().min(1).default(CONSTANTS.PAGINATION.PER_PAGE), pageNumber: Joi.number().min(1).default(1) });`

Here is an example value that is not working as expected:

?filters=[{"key":"userType","value":"STUDENT"}, {"type":"hash","key":"email","value":"ab8789789@gmail.com"}]

The issue I am having with celebrate is:

When I go to version 10 then celebrate is working fine and it is able to validate the params but when I just shift to v13 then it is not able to validate