-
Notifications
You must be signed in to change notification settings - Fork 419
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
Presence verifier has not been set exception on validator rule exists #584
Comments
It's only set if it was registered manually or you enabled eloquent. Did you uncomment Alternatively you can register your own presence verifier as |
I have not enabled Eloquent since I have no use for it in this particular project. I guess I could enable it even though I might get a small performance hit. I am not too familiar with validation internals in Laravel/Lumen. I was just wondering why this validation rule requires Eloquent anyway? The rule seems to be using the query builder syntax so I guess it is coming from somewhere else. https://github.com/laravel/framework/blob/5.4/src/Illuminate/Validation/Rules/Exists.php |
the |
Hmm, you are completely sure? Because the app I am building has |
I guess If you resolve the query builder later it will work because The problem is the validation service provider checks if the database service provider is already bound and skips registering the presence verifier if it's not. So it's not going to register the presence verifier unless you make the database component at least once before using the validator. |
Thanks for the the explanation but it goes way over my expertise :) Is this considered a bug or not? For me it does not make sense to require Eloquent for a certain validation rule, even though it is database related. |
I had the same issue for my custom validator class in Laravel 5.4. After doing some googling, I kinda fixed it ('RuntimeException: Presence verifier has not been set.' is not bugging me anymore ) by calling 'setPresenceVerifier' method in the constructor of my custom validator class.
Unless I find any other way to fix this, I am sticking with it. Hope this may help. Thank you. |
It's pretty old, but I got the same problem, and found a solution. To me it's a bug on Laravel, I'm trying to find a good way to fix it and open a PR to Laravel, but it's another matter.
|
Calling lumen-framework/src/Application.php Line 698 in a722705
It isn't really a bug. If you have not enabled the database component Lumen can't use it for the presence verifier. You can verify that is the case by looking at the line of code I linked previously: The other workaround is also doing the same thing. Resolving If Laravel didn't check for the The docs should probably be updated to state that the |
You'll indeed need to uncomment the |
I am having same issue with lumen 8 and |
@esinanturan try injecting The reason is, the validator is registered as So when you try to inject In general it's a good idea to stick to the contracts listed in the docs. If you try injecting a class there's no guarantee that class has a container binding. |
I am creating a manual validator like this:
The entry exists in the database, but I am getting the following error:
The text was updated successfully, but these errors were encountered: