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
Ad