I'm using laravel and i have a request form with rule like this:
'postal_code1' => 'required',
'postal_code2' => 'required_with:postal_code1|numeric',
and some html
<input type="text" name="postal_code1" />
<input type="text" name="postal_code2" />
The trouble i met that when i don't fill the postal_code1
,
I receive the error
Postal_code2 must be a number
How do numeric rule run only if the input is filled?
I tried the sometimes rule:
'postal_code2' =>'sometimes|required_with:postal_code1|numeric'
But not working