-
Notifications
You must be signed in to change notification settings - Fork 178
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
[QUESTION] Validation rules stopped working, Laravel maintainers suggest you provide new ones? #427
Comments
Extending the
Will review and merge a PR if anyone have the time to write it :) |
I'd have encountered the same issue and made the following solution for it to work. Probably there have been made some changes on the validator level and by changing it's logic a little you can make it work again with Doctrine. Like @eigan suggested you'll need to make a custom validation rule:
one side note here: I'm using full class names while passing it into the Rule like so:
as followed I've created a new Rule object which I'll call in my controllers, please note that this probably also could be overwritten on ServiceProvider level to overwrite the original 'unique' rule of Laravel itself.
now that we have created the rule itself and extended the helper we'll need to create our own custom validator instance like so:
the problem lays in last but not least we'll should add the following lines in for instance your AppServiceProvider under register():
hope this helps. Best, |
Thank you, it was helpful for me. |
This was fixed by me here laravel/framework#33481 |
Package version, Laravel version
laravel-doctrine/orm: 1.5.4
laravel/framework: 6.11.1
Expected behaviour
Where
My\Entities\Something
is a valid@ORM\Entity
with a constructor that has more than zero parameters:$x = \Illuminate\Validation\Rule::unique(My\Entities\Something::class);
Should return
\Illuminate\Validation\Rules\Unique
Actual behaviour
We upgraded
laravel/framework
from 6.5.1 to 6.11.0 and we now get:Too few arguments to function My\Entities\Something::__construct(), 0 passed in src/Illuminate/Validation/Rules/DatabaseRule.php on line 65 and at least 4 expected
Steps to reproduce the behaviour
Upgrade laravel/framework to anything above 6.6+ and try to instantiate a new
\Illuminate\Validation\Rules\Unique
with a a valid@ORM\Entity
that has a constructor with more than zero parameters. Same thing will happen withExists
, and anything else that usestrait \Illuminate\Validation\Rules\DatabaseRule
.Here's the commit that broke things: laravel/framework#30653
Here's a bug report about this issue that was closed upstream: laravel/framework#31180
Maintainer suggested:
This is why I opened this ticket.
Thank you for your time.
The text was updated successfully, but these errors were encountered: