laravel 自定义验证手机号



 public function rules()
 {
                $rules = [
                    'name'               => 'unique:merchants,name,'.$id.',id',
                    'mobile'             => 'required|numeric|min:10|max:10',
                    'dist_name'          => 'required',
                    'fare'               => 'sometimes|numeric',
                    'full_price'         => 'sometimes|numeric',
                    'city'               => 'required',
                    'address'            => 'required',
                ];
 }

以上是自定义的 验证规则

laravel 没有验证手机号的 ,添加一个验证规则 在 当前页面 怎么写呢

laravel php laravel5.1

Turtle 9 years, 10 months ago

/^13\d{9}$|^14\d{9}$|^15\d{9}$|^17\d{9}$|^18\d{9}$/

天使@翼神 answered 9 years, 10 months ago

'phone'=>'regex:/^1[34578][0-9]{9}$/'

艾露雅伊芙 answered 9 years, 10 months ago

Your Answer