I'm running into an issue with Larvel 5.8 where the validation rules, specifically URL and my custom MACAddress rule are being triggered regardless if the request-type variable is set (based on the required_if).
I even attempted to update the URL rule to reference the "sometimes" vs the required if but no change. I always see the response "The url format is invalid." even if it is not required.
return [
'name' => 'required',
'email' => 'required|email',
'reference-id' => 'required',
'request-by-date' => 'required|date',
'request-type' => 'required',
'description' => 'required',
'customer' => 'required|exists:customers,id',
'url' => 'url|required_if:request-type,url|unique:requests,url,approved,1',
'ip' => 'required_if:request-type,IP',
'mac-address' => ['required_if:request-type,DHCPReservation', new MACAddress],
'dhcp-device-type' => 'required_if:request-type,DHCPReservation',
'other-device-type' => 'required_if:dhcp-device-type,Other'
];
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire