How can I check if a value of a string is "0" in Laravel 5.3?
Here's my validation rules before processing the data:
// I want them to be anything but "0". So "01", "1" etc. are all okay
$rules = [
'state' => 'required',
'city' => 'required',
];
As the data is passed as strings I cannot use min:1 for this.
I'm sorry if this have already been asked, but I cannot find an answer. Many thanks!
This worked for me:
$rules = [
'state' => 'required|not_in:0',
'city' => 'required|not_in:0',
];
Also, have a look at this: Laravel 5.2 validation check if value is not equal to a variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With