AndrewKeig / express-validation

express-validation is an express middleware that validates a request and returns a response with errors; if any of the configured validation rules fail.
MIT License
393 stars 85 forks source link

How to apply default values in Joi schema? How to apply data modifiers? #170

Closed cacharrin closed 1 year ago

cacharrin commented 1 year ago

I used this schema for query:

{
   limit: Joi.number().default(10),
   reason: Joi.string().trim()
}

But retrieving req.query.limit the value is empty. Also sending reason=%20%20%20test%20%20%20 is not applying the trimeither

How about other modifiers that can be applied to Joi schemas? It seems to be validating only but not taking into account the result of the validation process, that is also critical.

cacharrin commented 1 year ago

Sorry, I just found the "context: true" parameter.