I have to write validation rule that should verify if address
is unique on rows where routing_id
has given value. That is simple. But in some cases routing_id
field may be NULL
and then my validation request rule doesn't work.
Here is my rule:
$rules['address'] = 'required|ip|unique:vias,address'.\Route::current()->getParameter('via')->id.',id,routing_id,'.request()->input('routing_id'));
When I am patching row with null
as routing_id
in my POST
array I want my address
to be unique within all rows with nulled routing_id
field. But it does not work.
And my question is: how to solve it?