0

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
}              
Xiidref
  • 669
  • 3
  • 14
  • 1
    What about this rule? https://respect-validation.readthedocs.io/en/latest/rules/When/ – PtrTon May 07 '21 at 14:51
  • Yes it work, i didn't think to use it this way ```Validator::when(Validator::key("a"), Validator::key("b"))->validate(parameters)``` thank you very much for this ! – Xiidref May 07 '21 at 15:01

0 Answers0