-1
Guys I have a user registration system, in this system has a CPF field, where I use a class to validate it, but the field is not mandatory, and all the classes I tried to validate Cpf, validates even if the field is empty because you understand that the empty field does not have a valid Cpf format. So my idea, not to mess with the class, is to check the Cpf field if it came empty/null, so just do the check.
I use it this way:
$rules = [
'email' => 'required|email|min:3|max:60|unique:users,email,
'name' => 'required|min:3|max:70',
'cpf' => 'cpf',
];
$this->validate($request, $rules);
I tried to use the required_if but I could not form the logica. If anyone can help I really appreciate.
This is Vinicius, thank you very much for the answer. I’m even using a class you created to validate Cpf, I downloaded it from git. I will try to do as you put it, then put the result.
– Rafael
thanks, thank you very much, solved my problem. Congratulations and success.
– Rafael