Closed
Description
Describe the bug
Validation of a json object body works, but validation of a json array body does not work.
To reproduce the bug
Create a validation spec similar to the following:
Validate: crud.Validate{
Body: crud.Array().Items(crud.String()),
},
Then send a request body with something like {}
. I would expect the error body validation failed for field body: wrong type passed
, but no validation error occurs.
Any other details
On the flip side, passing a json array for a json object body does fail validation correctly. For example:
Validate: crud.Validate{
Body: crud.Object(map[string]crud.Field{
"test": crud.String(),
}),
},
Then send a request body with something like []
. I get the following validation error:
body validation failed for field body: wrong type passed
which is what I would expect.