Closed limelier closed 4 years ago
celebrate
doesn't validate req.body
for GET requests. While it's technically allowed to have a body in GET requests per the HTTP spec, most people don't use GET that way. I also copied how hapi deals with this and hapi does not validate body on GET requests. The code around this is here.
Can you change your HTTP verb to POST instead?
I see, I wasn't familiar with that. Using the POST verb yields a validation error, as expected.
I'll add something to the docs clarifying this.
Note added in ea22b24ee98d6bc56b229f1613943dbb4d4104ca
node
version - 13.9.0celebrate
version - 12.0.1joi
version (vianpm ls --depth=0 | grep joi
) - 17.1.1My
joi
schema looks like this:Joi.array()
Here is an example value that is not working as expected:
{}
The issue I am having with
celebrate
is:Running
Joi.array().validate({});
produces the expected validation error, but sending{}
as a request body to the following route still prints{}
, even though it should not get through.What's going on?