Skip to content

Latest commit

 

History

History
88 lines (67 loc) · 1.7 KB

README.md

File metadata and controls

88 lines (67 loc) · 1.7 KB

Validators for Yii2

Validators for Yii2

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiier/yii2-validators "*"

or add

"yiier/yii2-validators": "*"

to the require section of your composer.json file.

Method Listing

中国身份证号码验证

public function rules()
{
    return [
        // ... 
        ['id_card', \yiier\validators\IdCardValidator::class],
        // code
    ];
}

Array Validator

public function rules()
{
    return [
        // ... 
        ['product_ids', \yiier\validators\ArrayValidator::class],
        // code
    ];
}

Phone Validator

public function rules()
{
    return [
        // ... 
        ['phone', \yiier\validators\PhoneValidator::class],
        // code
    ];
}

Money Validator

public function rules()
{
    return [
        // ... 
        ['amount', \yiier\validators\MoneyValidator::class],
        ['amount', \yiier\validators\MoneyValidator::class, 'allowsNegative' => true],
        // code
    ];
}

……