How to implement a validation rule in Laravel?

2

I would like to know how to validate a rule in the Auth form.

In this case, it is a CPF rule. Validation rules and error messages I already have, but I do not know how to implement it in the framework.

Should I put the rules directly in the Controller Validator?

    
asked by anonymous 08.09.2017 / 22:05

2 answers

0

I do not know any native form of laravel to do this validation, I already worked on a project where I needed to validate cpf and phone and the way was to use a library that is available in github at the following link:

link

You can install via composer by adding:

{
    "laravellegends/pt-br-validator" : "5.1.*"
}

In the link quoted above you have all the tips on how to use the library!

    
05.10.2017 / 20:48
0

I have the following repository to install in your Laravel project:

link

  • The main advantage of this specific project is that you can validate the CPF or CNPJ in the same field. Following:

    $ this-> validate ($ request,       'cpf_or_cnpj' = > 'format_cpf_cnpj | cpf_cnpj', ]);

  • Excellent documentation.

01.11.2018 / 02:12