yii2mod/yii2-validators

Collection of useful validators for Yii Framework 2.0

Installs: 10 960

Dependents: 0

Suggesters: 0

Security: 0

Stars: 18

Watchers: 4

Forks: 3

Open Issues: 0

Type:yii2-extension

1.2 2016-11-22 15:55 UTC

This package is not auto-updated.

Last update: 2021-11-27 01:58:23 UTC


README

Collection of useful validators for Yii Framework 2.0

Latest Stable Version Total Downloads License Build Status

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"yii2mod/yii2-validators": "*"

to the require section of your composer.json file.

Usage

  • Credit Card Validator
    public function rules()
    {
        return [
            [['creditCard'], \yii2mod\validators\ECCValidator::className()],
        ];
    }
  • Yii2 phone validator is a validator uses phone number util to validate and format the phone number attribute of model.
    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'], 
        ];
    }