GithubHelp home page GithubHelp logo

mhunesi / yii2-phone-validator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from udokmeci/yii2-phone-validator

0.0 1.0 0.0 9 KB

Yii2 phone validator is a validator uses phone number util to validate and format the phone number attribute of model.

PHP 100.00%

yii2-phone-validator's Introduction

yii2-phone-validator

Yii2 phone validator is a validator uses phone number util to validate and format the phone number attribute of model.

How to use?

##Installation with Composer Just add the line under require object in your composer.json file.

{
  "require": {
    "udokmeci/yii2-phone-validator" : "~1.0.3"
  }
}

then run

$> composer update

##Configuration Now add following in to your model rules. ###Note: ISO 3166-1 alpha-2 codes are required for country attribute. You can use db-regions for countries list.

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
          [['name', 'country'], 'string', 'max' => 50],
          // add this line
          [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator'],
        ];
    }

##Advanced The country and country_code attributes are tried if country or countryAttribute is not specified.

  // All phones will be controlled according to Turkey and formatted to TR Phone Number
  [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator','country'=>'TR'],// 

  //All phones will be controlled according to value of $model->country_code
  [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator','countryAttribute'=>'country_code'],

  //All phones will be controlled according to value of $model->country_code
  //If model has not a country attribute then phone will not be validated
  //If phone is a valid one will be formatted for International Format. default behavior.
  [['phone'], 'udokmeci\yii2PhoneValidator\PhoneValidator','countryAttribute'=>'country_code','strict'=>false,'format'=>true],  

Any forks are welcome.

yii2-phone-validator's People

Contributors

udokmeci avatar julianrutten avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.