Inconsistency in validation #38407
Unanswered
EduardoLeite96
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I detected a possible problem in the validation from the "unique" rule, for inserting and updating records.
"Unique" validation does not work for fields that contain only numbers. I have a field called "cpf" that contains up to 11 numeric digits and the "unique" validation doesn't validate correctly.
Validation works for email, as I've already tested it, however it doesn't work for this specific field that contains only numbers.
$validator = Validator::make($request->all(),
[
'modalCadastrarNome'=>'required|regex:/^[a-zA-ZÀ-ú0-9-. ]{5,60}+$/i',
'modalCadastrarCpf'=>'required|cpf|unique:clientes,cpf',
'modalCadastrarEmail'=>'required|email|unique:clientes,email',
]);
Example of a CPF: 607.437.910-61 (no dots or dashes, just numbers).
I'm not sure but in an older version of Laravel this same validation didn't give this problem.
Laravel version: 8.54.
PHP version: 8.
Database: MySQL8
Beta Was this translation helpful? Give feedback.
All reactions