Skip to content
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

Validation rules won't work until manual loading the provider once #27

Open
ametad opened this issue Jul 12, 2021 · 1 comment
Open

Comments

@ametad
Copy link

ametad commented Jul 12, 2021

Hi @antonioribeiro ,

Thank you for your work on this package.
I have a question on the validation rules that I don't seem to get working. It looks like the validation rules are not yet loaded before you load app('pragmarx.countries'); explicitly. After that the validation does work correctly.

Version "pragmarx/countries-laravel" === '0.6.3'

Example steps to reproduce the error

class PostController extends Controller

    public function store(Request $request)
    {
        // Without this the 'cca2' validation rule gives error. Please toggle on/off.
        $foo = app('pragmarx.countries');

        $validated = $this->validate($request, [
           'country_code' => 'nullable|string|size:2|cca2',
        ];

        dd($validated);
    }

The error I get when the rule is not loaded:

Method Illuminate\Validation\Validator::validateCca2 does not exist.

Perhaps this has something to do with the defered state in \PragmaRX\CountriesLaravel\Package\ServiceProvider ?

@ametad
Copy link
Author

ametad commented Jul 12, 2021

I guess this is a problem for some time now, according to #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant