1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
return [ [['username','password','email','phone','images'],'required','message'=>'不能为空'], //验证唯一性 [['username'], 'unique','targetClass' => '\backend\models\Verification','message'=>'用户名不能一致'], //验证长度 ['username', 'string', 'min' => 2, 'max' => 8,"tooLong"=>"太长了", "tooShort"=>"太短了"], //正则验证 ['username','match','pattern'=>'/^[a-z]{1,}$/','message'=>'用户名必须为字母'], ['password','match','pattern'=>'/^[0-9]{6,12}$/','message'=>'密码必须是数字,且大于6为小于12位'], ['email', 'unique', 'targetClass' => '\backend\models\Verification', 'message' => '邮箱名已存在.'], //邮箱验证 ['email','match','pattern'=>'/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/','message'=>'邮箱格式不正确'], //手机号验证 ['phone','match','pattern'=>'/^1[0-9]{10}$/','message'=>'手机号格式不正确'], ]; |