2017 © Pedro Peláez
 

yii2-extension yii2-ip-validator

Yii2 IP address validator

image

alexeevdv/yii2-ip-validator

Yii2 IP address validator

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

yii2-ip-validator

Yii2 ip address validator. Can check that IP address is valid or in given range, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

$ php composer.phar require alexeevdv/yii2-ip-validator "dev-master"

or add, (*4)

"alexeevdv/yii2-ip-validator": "dev-master"

to the require section of your composer.json file., (*5)

Usage

public function rules() {
    return [
        //...
        ['ip', \alexeevdv\ip\Validator::className(), "range" => [
            "192.168.1.1", 
            "10.62.15.0/24", 
            "109.232.0.0/16"
        ]],
        //...
    ];
}

// or

$validator = new \alexeevdv\ip\Validator([
    "allowPrivate" => false,
    "allowReserved" => false,
]);

$validator->validate("127.0.0.1"); // false

Params

/**
 * Allow private ip addresses?
 * 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16
 */
bool $allowPrivate = true;

/**
 * Allow reserved ip addresses?
 * 0.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24 and 224.0.0.0/4
 */
bool $allowReserved = true;

/**
 * Range of allowed ip addresses. Array of subnets and ip addresses.
 */
array $range = [];

The Versions

22/09 2015

dev-master

9999999-dev

Yii2 IP address validator

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 validator address ip ipv6 ipv4