-
Notifications
You must be signed in to change notification settings - Fork 43
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
Validators do not get added due to deferred service provider #14
Comments
I'm having the exact same problem. To me it looks like it became a problem since laravel 5.7. @hackel could you explain your workaround in a little more detail? I can't seem to get it working. Thanks. |
@handyface I literally just added This isn't really ideal, since only a a couple of my routes actually require the validator, and so the service gets loaded for nothing. I also thought about using a middleware to load the provider prior to hitting my FormRequest class only when it is needed, but haven't gotten around to it yet. |
@hackel Thanks for the response. I tried it but for me this produces errors, so I'm removing the validation altogether for now. |
Add |
Also worked when I call |
I just upgraded from 0.5.2 and discovered that the validations no longer work, throwing a
BadMethodCallException: Method Illuminate\Validation\Validator::validateCca2 does not exist.
I discovered that the validator extensions were not being loaded at all, and traced that back to the service provider now being deferred.As a workaround, I just added
app('pragmarx.countries');
to my own AppServiceProvider to manually resolve the provider on every request, which then registers the validator extensions, and everything is happy again.I'm not sure of the best solution to this issue. Perhaps it would be best to convert the validation extensions to Rule objects that will resolve the provider when needed without having to disable deferred loading all together.
The text was updated successfully, but these errors were encountered: