Reputation: 311
I have a form with dynamic inputs which are like: min_1,$min_2,...$min_1000,$max_1000, I want to validate these elements to be numeric and to be required. As i am not sure about the name of inputs to be validated, how can i write the role. I need some thing like $min_(what ever): required|numeric I appreciate any help. Thank you
Upvotes: 2
Views: 146
Reputation: 422
Please try the following:
foreach($request->all() as $item)
{
$rule[$item] => "required|string"
}
Validator::make($request->all(),$rule);
Let me know If you get any errors.
Don't forget to mark it answer if works
Hope it helps you
Thank you
Upvotes: 1