i'm new to laravel and i would like to know if there are a way to use or/else conditional in $rules, because I am struggling trying to do the following validation: If the field is Z the size must be y, else, x. I tried this, but it always validade data with size:11
'type => 'required',
'field' => ['required', ('type == 1' ? 'size:11' : 'size:14')],
Anyone has a clue? thanks in advance
I assume you use Form request validation so you can do something like this:
$rules = [
'type' => 'required',
'field' => ['required'];
];
$rules['field'][] = ($this->input('type') == 1) ? 'size:11' : 'size:14';
return $rules;