mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 08:42:15 +02:00
Tests and docs for IP range validation
This commit is contained in:
parent
55290af1fd
commit
7e7c3f2fcc
|
@ -14,6 +14,13 @@ v::ip('220.78.168.0/21')->validate('220.78.173.2'); // true
|
|||
v::ip('220.78.168.0/21')->validate('220.78.176.2'); // false
|
||||
```
|
||||
|
||||
Validating ranges:
|
||||
|
||||
```php
|
||||
v::ip('127.0.0.1-127.0.0.5')->validate('127.0.0.2'); // true
|
||||
v::ip('127.0.0.1-127.0.0.5')->validate('127.0.0.10'); // false
|
||||
```
|
||||
|
||||
You can pass a parameter with [filter_var()][] flags for IP.
|
||||
|
||||
```php
|
||||
|
|
|
@ -53,6 +53,7 @@ final class IpTest extends RuleTestCase
|
|||
[new Ip('220.78.168/21'), '220.78.173.2'],
|
||||
[new Ip('220.78.168.0/21'), '220.78.173.2'],
|
||||
[new Ip('220.78.168.0/255.255.248.0'), '220.78.173.2'],
|
||||
[new Ip('127.0.0.1-127.0.0.5'), '127.0.0.2'],
|
||||
[new Ip('*', FILTER_FLAG_IPV6), '2001:0db8:85a3:08d3:1319:8a2e:0370:7334'],
|
||||
];
|
||||
}
|
||||
|
@ -78,6 +79,7 @@ final class IpTest extends RuleTestCase
|
|||
[new Ip('193.168.0.0-193.255.255.255'), '192.10.2.6'],
|
||||
[new Ip('220.78.168/21'), '220.78.176.1'],
|
||||
[new Ip('220.78.168.0/21'), '220.78.176.2'],
|
||||
[new Ip('127.0.0.1-127.0.0.5'), '127.0.0.10'],
|
||||
[new Ip('220.78.168.0/255.255.248.0'), '220.78.176.3'],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue