๖ۣۜI๖ۣۜO๖ۣۜS ۣۜ 2019-07-24 16:21:19 238次浏览 1条回复 2 0 0
public function rules()
{
    return [
        ['username', 'filter', 'filter' => 'trim'],
        ['username', 'required'],
        ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => '该用户名已经被占用.'],
        ['username', 'string', 'min' => 4, 'max' => 12],
        ['username','match','pattern'=>'/^[a-zA-Z0-9_]+$/','message'=>'{attribute}只能由英文字母、数字、下划线组成'],

        ['realname', 'filter', 'filter' => 'trim'],
        ['realname', 'required'],
        ['realname', 'string', 'min' => 2, 'max' => 4],
        ['realname','match','pattern'=>'/^[\x{4e00}-\x{9fa5}]+$/u','message'=>'{attribute}必须为中文汉字'],

        ['organization_name', 'required'],
        ['organization_name', 'filter', 'filter' => 'trim'],
        ['organization_name', 'string', 'min'=>4,'max' => 20],

        ['email', 'required'],
        ['email', 'email'],
        ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => '该电子邮箱已经被占用.'],

        ['mobile', 'required'],
        ['mobile', 'integer'],
        ['mobile','match','pattern'=>'/^1[0-9]{10}$/','message'=>'{attribute}必须为1开头的11位纯数字'],
        ['mobile', 'string', 'min'=>11,'max' => 11],
        ['mobile', 'unique', 'targetClass' => '\common\models\User', 'message' => '该手机号码已经被占用.'],

        ['smsCode', 'required'],
        ['smsCode', 'integer'],
        ['smsCode', 'string', 'min'=>4,'max' => 4],
        //['smsCode', 'required','requiredValue'=>$this->getSmsCode(),'message'=>'手机验证码输入错误'],

        ['password', 'required'],
        ['password', 'string', 'min' => 6,'max' => 16,'message'=>'{attribute}位数为6至16位'],
    ];
}
亿速云
您需要登录后才可以回复。登录 | 立即注册