Is there a way to set a validation on multiple inputs with similar name? For ex -
public function rules()
{
return [
'zone1' => 'required|numeric',
'zone2' => 'required|numeric',
'zone3' => 'required|numeric',
];
}
Can I do something like 'zone*' => 'required|numeric'
You can use an asterisk as a wildcard but it may not be a great idea. With a rule like 'zone*' => 'required|numeric'
as long as there's a single value that matches the condition the request will pass validation. For example, if a request has a valid value for zone2
but zone1
and zone3
are missing or non-numeric the validation will still pass