Yii2中的规则
//Yii2中的规则,用户名的规则,1、用户名只能是字母 2、判断用户名已经存在 3、用户名的长度 4、用户名不能为空
[['username'], 'match', 'pattern' => '/^[a-z]\w*$/i'],
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => '用户名已存在'],
['username', 'string', 'min' => 5, 'max' => 255],
//Yii2中的规则,电话号码的规则
['mobile_phone', 'required','message' => '手机号码不能为空'],
['mobile_phone', 'filter', 'filter' => 'trim'],
[['mobile_phone'], 'match', 'pattern' => '/^(1(([35][0-9])|(47)|[8][0126789]))\d{8}$/'],
['mobile_phone', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This mobile phone number has already been taken.'],
//密码的规则,重复密码的规则
['password', 'required'],
['password', 'string', 'min' => 6],
['rePassword', 'compare', 'compareAttribute' => 'password'],
//邮箱的规则
['email','email','message' => '您输入的邮箱错误'],
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => '这个邮箱已经被注册了'],
//url规则
['store_logo', 'url'],
['start_time', 'filter', 'filter' => 'strtotime'],
['end_time', 'filter', 'filter' => 'strtotime'],
//默认值
['status', 'default', 'value'=>self::STATUS_CHECK],
最新文章
- 带有静态方法的类(java中的math类)
- 【leetcode】Insert Interval(hard)★
- BZOJ3417 : Poi2013 Tales of seafaring
- 第七章 企业项目开发--本地缓存guava cache
- Python字典笔记
- 基于React服务器端渲染的博客系统
- [4X]荣耀畅玩4X开箱实录
- selenium资料
- ASP.NET-FineUI开发实践-13(二)
- asp.net mvc3 数据验证(四)—Remote验证的一个注意事项
- 2017年PHP培训机构排名
- Windows7 64位安装最新版本MySQL服务器
- 464. Can I Win
- Nginx 在 Linux 上的安装和配置
- 破解xlsm文件的VBA项目密码和xlsx的工作簿保护密码
- Hadoop.之.入门部署
- oracle 锁表查看与解锁
- 转:queue
- apache目录别名
- eclipse中的项目鼠标右键卡死
热门文章
- 查看tomcat的版本号
- The user specified as a definer ('root'@'%') does not exist解决
- MySQL事务调优
- 推荐五个java基础学习网站,小白必备
- 阿里云移动研发平台EMAS,是如何连续5年安全护航双11的?
- java版扫雷
- nginx 配置多服务器代理
- 【Tomcat】2.配置Tomcat服务器端口和HTTPS
- mybatis plus CRUD
- 内核module读取进程页目录