'require|length:3,30', 'member_truename'=>'require|checkTruename', 'member_idcard'=>'require|checkIdcard', 'member_password'=>'require|length:6,20', 'member_email'=>'email', 'member_mobile'=>'length:11,11', 'member_nickname'=>'max:10', ]; protected $message = [ 'member_name.require'=>'User name is required', 'member_name.length'=>'The user name is between 3 and 13 characters long', 'member_truename.require'=>'Real name is required', 'member_truename.checkTruename'=>'Wrong real name', 'member_idcard.require'=>'身份证必填', 'member_idcard.checkIdcard'=>'身份证错误', 'member_password.require'=>'Password is required', 'member_password.length'=>'Password must be 6-20 characters.', 'member_email.email'=>'邮箱格式错误', 'member_mobile.length'=>'手机格式错误', 'member_nickname.max'=>'真实姓名长度超过10位', ]; protected $scene = [ 'add' => ['member_name', 'member_password', 'member_email'], 'edit' => ['member_email', 'member_mobile', 'member_email'], 'edit_information' => ['member_nickname'], 'login' => ['member_name', 'member_password'], 'register' => ['member_name', 'member_password'], 'auth' => ['member_truename', 'member_idcard'], ]; protected function checkTruename($value,$rule,$data) { return preg_match('/^[\x{4e00}-\x{9fa5}]{2,4}$/u',$value)?true:false; } protected function checkIdcard($value,$rule,$data) { return preg_match('/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/',$value)?true:false; } }