I am using Zend Standard Validation Classes (http://framework.zend.com/manual/1.12/en/zend.validate.set.html) to validate requests to an api.
You basically specify each request parameter and a set of rules for validating each parameter.
Is it possible to specify that there can be 2 (or more) options when validating a given request, depending on what parameters are in the request?
Like for example if you post:
{
"a": "someVal",
"b": "someVal",
"c": "someVal",
"d": "someVal"
}
then a, b, c, and d are required fields, but if you post like this:
{
"a": "someVal",
"e": "someVal",
"f": "someVal",
"g": "someVal"
}
then a, e, f and g are required fields?
If you examine the data above you will notice that field "b" is a required field in one POST, but it is an optional field in the other POST.
QUESTION:
How do you specify that a request may be validated in 1 of 2 (or more) ways? How do you specify that a request should be validated based on what parameters are in the request? Is this possible, and how?
Have been stuck on this one for a while so any assistance would be great..
Zend Framework 2.2