-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use multiple requiring rules #647
Comments
Yeah this is a difficult one, and probably one for v5 it basically requires a rewrite of the whole rule inferring system. The Then the I've quickly tried a special method when adding the attributes, to not replace the requires but that also fails in a lot of tests. We need a new RuleInferrer for this, basically one that completely replaces the existing ones we have and merges them into one rule inferrer so that we can be smarter about inferring rules. At the moment we don't have an idea what's happening in the other rule inferrers. Technically, this shouldn't be a breaking change since we could just add that rule inferrer, I'll take a look in the coming weeks if I can find the time to implement such a thing. PR's are also always welcome. I've already added a test which tests this case: laravel-data/tests/ValidationTest.php Lines 279 to 290 in e954107
|
Dear contributor, because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it. |
Dear contributor, because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it. |
✏️ Describe the bug
Adding multiple requiring rules to a property/parameter only results in the last added requiring rule being applied. For example, if a
RequiredUnless
rule is used alongside aRequiredWith
rule, only theRequiredWith
rule will be applied (assuming that theRequiredWith
rule is last).The offending lines seem to be:
laravel-data/src/Support/Validation/PropertyRules.php
Lines 40 to 44 in 324970e
↪️ To Reproduce
✅ Expected behavior
In the scenario above, I expect the
a
property to have the requiring rules['required_unless:requires_a,false', 'required_with:b']
. However, thea
property only has therequired_with:b
. Laravel does offer the ability to apply multiple requiring rules at once, as demonstrated here:I expect requiring rules to be applied even if they are of the same type. The only requiring rule that I would expect to not be duplicated is the plain
Required
rule.🖥️ Versions
Laravel: 10.x
Laravel Data: 3.11.0
PHP: 8.1.15
The text was updated successfully, but these errors were encountered: