requiredIf()
requiredIf()
Section titled “requiredIf()”requiredIf($field, $value) makes a field required when the other field strictly equals the given value.
$rules->string('companyName') ->optional() ->requiredIf('accountType', 'business');Conditional rules need the DTO object, so use them in registered object validation.