I have a form with 2 numeric fields: kg_bags and g_bags.
At least one of them is required, and must be greater than Zero.
My validation:
$this->validate($request,[
"kg_bags" => "bail|required_without:g_bags|required_if:g_bags,'<=',0|numeric|min:1",
"g_bags" => "bail|required_without:kg_bags|required_if:kg_bags,'<=',0|numeric|min:1"
],
[
'kg_bags.required_if' => 'Please fill in the number of bags you packed',
'kg_bags.required_without' => 'Please fill in the number of bags you packed',
'kg_bags.min' => 'How did you pack less than Zero bags?',
'g_bags.required_if' => 'Please fill in the number of bags you packed',
'g_bags.required_without' => 'Please fill in the number of bags you packed',
'g_bags.min' => 'How did you pack less than Zero bags?'
]);
This does not work as I want.
If I submit:
kg_bags = empty
g_bags = -1
I get the error: kg_bags must be numeric instead of: How did you pack less than Zero bags?
Why is that?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zBrUsq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire