Validating Numeric Input Length in Laravel 5
To specify the expected length of a numeric input in Laravel 5, the initial approach using 'size' validation rule may not suffice. Instead, you can employ the 'digits' rule as follows:
foo.blade.php:
FooController.php:
$rules = [ 'national-id' => 'required|digits:10' ];
The 'digits' rule ensures that the provided input contains the specified number of digits. In this case, it verifies that the 'national-id' field contains 10 digits, without requiring an exact match. Additionally, the 'required' rule ensures that the field is not empty before performing the length validation.
By using the 'digits' rule, you can effectively validate the length of numeric inputs in your Laravel 5 applications.
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