When validating the length of a numeric input in Laravel 5, one might encounter issues with the size rule. Instead of checking the length of the input, it checks if the input is exactly equal to the specified size.
To address this, the digits rule should be used. According to the Laravel documentation:
$rules = [ 'national-id' => 'required|digits:10' ];
The digits rule validates that the input is a numeric value with a length equal to the specified number. In this case, the national-id field should contain 10 digits.
The numeric rule is redundant in this scenario as the digits rule already verifies if the input is numeric.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3