Implementing rules()
on a top level object will disable underlying validation
#132
Unanswered
arondeparon
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Hi @arondeparon, Could you provide me a test which shows where this is going wrong? We have a test for nested data collections with overwritten rules : https://github.com/spatie/laravel-data/blob/main/tests/Resolvers/DataValidationRulesResolverTest.php#L74-L90 and it seems to be working fine to me. |
Beta Was this translation helpful? Give feedback.
4 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.
-
I am not sure if this intended, a bug or just my ignorance, but I have noticed the following:
When I add a
rules()
method to a top level object that contains aDataCollection
property which also implements arules()
method, the underlying rules method will be called.Example:
Looking at the code, this seems to be caused by this line:
It seems like mentioning an underlying property will basically "overwrite" the validation and ignore anything that happens after that.
So, the question: how would I implement this pattern while making sure that every validator is called?
Beta Was this translation helpful? Give feedback.
All reactions