Model Validation in laravel 5.1 not working
Ad
I am writing a rule in Model for mobile number validation this should be required, 10 digit , and must numeric. My rule is
'phone'=>'required|numeric|min:10'
It check up to 2nd level mean required and numeric validation but not min validation please help me to fix this.
Thank you in advance.
Ad
Answer
Ad
When validation like min/max/size are applied to numeric values, they're applied to the value, not the length. So in your case your validation makes sure that given number is larger or equal to 10.
Have a look at digits validation, it lets you define the exact number of digits a number should have: http://laravel.com/docs/5.1/validation#rule-digits
'phone' => 'required|numeric|digits:10'
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad