Validate CPF in Laravel's RegisterController class

0

I downloaded the link package to perform cpf validation on my system. I followed the documentation instructions by putting the ValidatorProvider in app.php.

In my system of registration, I would like only valid CPFs to be saved. However, I did not understand how to proceed with this validation in the RegisterController. I tried the following:

protected function validator(array $data)
{
    return Validator::make($data, [
        'cpf' => 'formato_cpf',
        'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255|unique:users',
        'password' => 'required|string|min:6|confirmed',
    ]);
}

But it did not work. As much as I put an invalid cpf I still can do the registration in the system. What am I doing wrong?

    
asked by anonymous 16.11.2018 / 16:22

1 answer

0

When I asked the question I was already a little desperate because I used 'cpf' and it did not work, then I had been trying the 'cpf' format, obviously unsuccessful as well. However, today I tested with 'cpf' and finally the validation worked. I do not understand what happened the first time, maybe it was necessary to restart the server or the composer had not mapped the Laravel Legends namespace. I will never know, but now everything is working.

    
17.11.2018 / 22:07