yii2 rules验证规则大全
required : 必须值验证属性
[['name','email'],'required']
[['name'],'required','message'=>'提示信息']
email : 邮箱验证
[['email'], 'email','message'=>'邮箱格式错误'],
match : 正则验证
[
'phone',
'match',
'pattern' => '/^13[0-9]{9}$|14[0-9]{9}$|15[0-9]{9}$|17[0-9]{9}$|18[0-9]{9}$/',
'message' => '手机号格式不正确'
]
url : 网址
['url', 'url', 'defaultScheme' => 'https']
captcha : 验证码
['verificationCode', 'captcha']
compare : 比较
['email', 'compare', 'compareValue' => 30, 'operator' => '>=']
filter : 滤镜
[['name', 'email'], 'filter', 'filter' => 'trim', 'skipOnArray' => true]
in : 范围
['level', 'in', 'range' => [1, 2, 3]];
unique : 唯一性
['username', 'unique']
integer : 整数
['age', 'integer']
number : 数字
['salary', 'number']
date : 日期
[['start'], 'date', 'format'=>'yyyy/MM/dd HH:mm:ss']
string : 字符串
['username', 'string', 'length' => [4, 24]];
ip:验证IP
['ip', 'ip']
标签:name,验证,rules,ip,message,yii2,email,大全
From: https://www.cnblogs.com/hu308830232/p/18105414