mardi 24 décembre 2019

Laravel validation URL failing even with sometimes perimeter set

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'
];


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2MratUp
via IFTTT

Aucun commentaire:

Enregistrer un commentaire