Issue
How to set not require numeric validation for Laravel5.2? I just used this Code but when i don't send value or select box haven't selected item I have error the val field most be numeric... I need if request hasn't bed input leave bed alone. leave bed validate ...
$this->validate($request, [
'provinces_id' => 'required|numeric',
'type' => 'required',
'bed' => 'numeric',
]);
Solution
If I understood you correctly, you're looking for sometimes
rule:
'bed' => 'sometimes|numeric',
In some situations, you may wish to run validation checks against a field only if that field is present in the input array. To quickly accomplish this, add the
sometimes
rule to your rule list
Answered By - Alexey Mezenin
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.