0

Is it possible to add validation if another validation passed for example I have the following validation rules

return [
    'name' => ['required', 'string', 'min:3', 'max:30'],
    'password' => ['required', 'min:6'],
    'photo' => ['imageable'],
    'business_uuid' => ['required', 'uuid', 'exists:businesses,uuid'],
];

and I would like if the business_uuid validation passed to add validation for the phone number

'phone' => ['nullable', 'phone:'.$countryCode],

notice that I'm the country code will be brought from the business That's why I'm I'd like to add it if the validation passed

3
  • If the business_uuid is required so if it doesn't pass then the whole validation will fail. I'm not understanding why you don't want to just add the phone validation anyway.
    – Rwd
    Commented Nov 28, 2021 at 17:46
  • I'm getting the country code from the $business->country so when I try to add the phone validation in the same rule it doesnt work cause it depends on the $business->country Commented Nov 28, 2021 at 21:32
  • Where/how are you getting $countryCode in the Form Request i.e. please can you show the code for your whole Form Request class?
    – Rwd
    Commented Nov 28, 2021 at 21:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.