Home > Article > Backend Development > How to Validate Length of Numeric Input with Digits Rule in Laravel 5?
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.
The above is the detailed content of How to Validate Length of Numeric Input with Digits Rule in Laravel 5?. For more information, please follow other related articles on the PHP Chinese website!