I'm trying to validate a CAB code of a bank.
The rules are that the CAB it MUST be numeric, and composed by 5 digits. I'm trying to validate this into a FormRequest class in Laravel 5.3
I've tried to set the validation like this:
"cab" => "required|max:5|min:5",
It works, but if the user pass a normal character (non numeric) in between, the validation passes since the string does not exceed the 5 chars length. So this is bad.
I've tried to set the validation like this:
"cab" => "required|max:5|min:5|numeric",
but if the user pass 55555 it will fail because the number is greater than 5.
I'm wondering if there's a way to perform a validation that says:
The input must be numeric, but the count of the total digits can't be greater than 5.
Am I missing something? Thanks for any help