Dependent parameters with Respect\Validation

295 Views Asked by At

I'm making input validation in my controllers using Respect\Validation library. I have two parameters that are optional but dependent, if the "a" parameter is present then I also need the "b" to be here and vice-versa and it is possible that there is none of them.

For now i have the following but it allow for "a" or "b" to be present.

if(!Validator::keySet(Validator::key("a", Validator::intVal(), false),
                      Validator::key("b", Validator::intVal(), false))->validate($parameters)){
    //Then something is wrong
}              
0

There are 0 best solutions below