yii2mod / yii2-validators
Yii Framework 2.0 的实用验证器集合
1.2
2016-11-22 15:55 UTC
Requires
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-14 17:16:19 UTC
README
Yii Framework 2.0 的实用验证器集合
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require --prefer-dist yii2mod/yii2-validators "*"
或者将以下内容添加到你的 composer.json
文件的 require 部分:
"yii2mod/yii2-validators": "*"
使用方法
- 信用卡验证器
public function rules() { return [ [['creditCard'], \yii2mod\validators\ECCValidator::className()], ]; }
- Yii2 电话验证器是一个使用电话号码工具来验证和格式化模型中电话号码属性的验证器。
public function rules() { return [ [['phone'], \yii2mod\validators\PhoneValidator::className(), 'country' => 'US'], // OR [['phone'], \yii2mod\validators\PhoneValidator::className(), 'countryAttribute' => 'country'], // OR [['phone'], \yii2mod\validators\PhoneValidator::className(), 'countryCodeAttribute' => 'countryCode'], ]; }