Repository navigation
Using "required_if" validation rule with an enum value #48500
Replies: 1 comment
|
For future reference, 'rules' => fn (array $args) => [
Rule::requiredIf(function () use ($args) {
return $args['payment_method'] === PaymentMethod::DebitReceipt;
}),
], |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Is there a more elegant way to do this?
I want to use the required_if validation rule to check if another field in the request is equal to a value contained in an enum.
My code right now:
I have categorised this as a Q&A because I do not know if there is already a better (more Laravel-like) way to do this, if not it could be categorised as a feature idea.
Thank you!
All reactions