Validations not working for parameters 3 level deep
Any type of validations are not working for the third_level, the parameters under the third level (id, quantity and groupid) can be null or can have any data types. And the parameters under the second_level works totally fine with all the validations.
requires :first_level, type: Hash do
optional :second_level, type: Array do
requires :id, type: Integer, desc: "id"
requries :value, type: Float, desc: "value"
optional :third_level, type: Array do
requires :id, type: Integer, desc: "timeslot id"
requires :quantity, type: Float, desc: "quantity"
optional :groupid, type: Integer, desc: "diethabit id"
end
end
end
end
In the above example, if send the below parameters they are getting accepted.
"first_level": {
"second_level": [
{
"id": 1,
"value": 0.5,
"third_level": [
{
"quantity": "some string value",
"groupid": false
}
]
}
]
}
}
Required id is missing, quantity have some string value and groupid is a boolean value.
This is happening only on 3 levels deep and working fine on above levels. Let me know if you need any more details.
Grape Version 0.19.2
Ruby Version 2.4.1
You should turn this into a spec, please. We have a lot of tests with many levels, I am pretty sure.
I added a spec for this case (https://github.com/ruby-grape/grape/pull/1793) and it seems that it's validating just fine in deeper levels of nested params.
@tabz24 Care to compare to what you have?
Thanks @Morred !
I'm closing this. Spec looks good for this exact scenario. @tabz24 Please make sure you're trying against the latest grape and reopen if this is an issue with a better repro.