Rename rule "Arr" to "ArrayVal"

This commit is contained in:
Henrique Moody 2015-10-07 12:25:15 -03:00
parent f2ab275751
commit 5863903e48
12 changed files with 28 additions and 28 deletions

View file

@ -1,12 +1,12 @@
# Arr
# ArrayVal
- `v::arr()`
- `v::arrayVal()`
Validates if the input is an array or traversable object.
```php
v::arr()->validate(array()); //true
v::arr()->validate(new ArrayObject); //true
v::arrayVal()->validate(array()); //true
v::arrayVal()->validate(new ArrayObject); //true
```
***

View file

@ -20,7 +20,7 @@ This function returns an array containing `scheme`, `host`, `path` and `query`.
We can validate them this way:
```php
v::arr()->key('scheme', v::startsWith('http'))
v::arrayVal()->key('scheme', v::startsWith('http'))
->key('host', v::domain())
->key('path', v::stringType())
->key('query', v::notEmpty());
@ -31,7 +31,7 @@ Using `v::call()` you can do this in a single chain:
```php
v::call(
'parse_url',
v::arr()->key('scheme', v::startsWith('http'))
v::arrayVal()->key('scheme', v::startsWith('http'))
->key('host', v::domain())
->key('path', v::stringType())
->key('query', v::notEmpty())

View file

@ -14,8 +14,8 @@ $releaseDates = array(
'relational' => '2011-02-05',
);
v::arr()->each(v::date())->validate($releaseDates); //true
v::arr()->each(v::date(), v::stringType()->lowercase())->validate($releaseDates); //true
v::arrayVal()->each(v::date())->validate($releaseDates); //true
v::arrayVal()->each(v::date(), v::stringType()->lowercase())->validate($releaseDates); //true
```
Using `arr()` before `each()` is a best practice.
@ -24,4 +24,4 @@ Using `arr()` before `each()` is a best practice.
See also:
* [Key](Key.md)
* [Arr](Arr.md)
* [ArrayVal](ArrayVal.md)

View file

@ -27,7 +27,7 @@ The type as the first validator in a chain is a good practice,
since length accepts many types:
```php
v::arr()->length(1, 5)->validate(array('foo', 'bar')); //true
v::arrayVal()->length(1, 5)->validate(array('foo', 'bar')); //true
```
A third parameter may be passed to validate the passed values inclusive:

View file

@ -25,7 +25,7 @@ v::intVal()->notEmpty()->validate(0); //false
Empty arrays:
```php
v::arr()->notEmpty()->validate(array()); //false
v::arrayVal()->notEmpty()->validate(array()); //false
```
Whitespace:

View file

@ -13,7 +13,7 @@ v::type('object')->validate(new stdClass()); //true
***
See also:
* [Arr](Arr.md)
* [ArrayVal](ArrayVal.md)
* [BoolType](BoolType.md)
* [CallableType](CallableType.md)
* [Finite](Finite.md)

View file

@ -2,7 +2,7 @@
## Types
* [Arr](Arr.md)
* [ArrayVal](ArrayVal.md)
* [BoolType](BoolType.md)
* [CallableType](CallableType.md)
* [Date](Date.md)
@ -92,7 +92,7 @@
## Arrays
* [Arr](Arr.md)
* [ArrayVal](ArrayVal.md)
* [Contains](Contains.md)
* [Each](Each.md)
* [EndsWith](EndsWith.md)
@ -182,7 +182,7 @@
* [Alpha](Alpha.md)
* [AlwaysInvalid](AlwaysInvalid.md)
* [AlwaysValid](AlwaysValid.md)
* [Arr](Arr.md)
* [ArrayVal](ArrayVal.md)
* [Attribute](Attribute.md)
* [Bank](Bank.md)
* [BankAccount](BankAccount.md)

View file

@ -11,7 +11,7 @@
namespace Respect\Validation\Exceptions;
class ArrException extends ValidationException
class ArrayValException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(

View file

@ -15,7 +15,7 @@ use ArrayAccess;
use Countable;
use Traversable;
class Arr extends AbstractRule
class ArrayVal extends AbstractRule
{
public function validate($input)
{

View file

@ -24,7 +24,7 @@ use Respect\Validation\Rules\Key;
* @method static Validator alpha(string $additionalChars = null)
* @method static Validator alwaysInvalid()
* @method static Validator alwaysValid()
* @method static Validator arr()
* @method static Validator arrayVal()
* @method static Validator attribute(string $reference, Validatable $validator = null, bool $mandatory = true)
* @method static Validator bank(string $countryCode)
* @method static Validator bankAccount(string $countryCode)

View file

@ -17,16 +17,16 @@ class TestAccess extends \ArrayObject implements \ArrayAccess, \Countable, \Trav
/**
* @group rule
* @covers Respect\Validation\Rules\Arr
* @covers Respect\Validation\Exceptions\ArrException
* @covers Respect\Validation\Rules\ArrayVal
* @covers Respect\Validation\Exceptions\ArrayValException
*/
class ArrTest extends \PHPUnit_Framework_TestCase
class ArrayValTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected function setUp()
{
$this->object = new Arr();
$this->object = new ArrayVal();
}
/**
@ -41,7 +41,7 @@ class ArrTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider providerForNotArray
* @expectedException Respect\Validation\Exceptions\ArrException
* @expectedException Respect\Validation\Exceptions\ArrayValException
*/
public function testNotArraysShouldThrowArrException($input)
{

View file

@ -25,19 +25,19 @@ class CallTest extends \PHPUnit_Framework_TestCase
public function testCallbackValidatorShouldAcceptEmptyString()
{
$v = new Call('str_split', new Arr());
$v = new Call('str_split', new ArrayVal());
$this->assertTrue($v->assert(''));
}
public function testCallbackValidatorShouldAcceptStringWithFunctionName()
{
$v = new Call('str_split', new Arr());
$v = new Call('str_split', new ArrayVal());
$this->assertTrue($v->assert('test'));
}
public function testCallbackValidatorShouldAcceptArrayCallbackDefinition()
{
$v = new Call(array($this, 'thisIsASampleCallbackUsedInsideThisTest'), new Arr());
$v = new Call(array($this, 'thisIsASampleCallbackUsedInsideThisTest'), new ArrayVal());
$this->assertTrue($v->assert('test'));
}
@ -45,7 +45,7 @@ class CallTest extends \PHPUnit_Framework_TestCase
{
$v = new Call(function () {
return array();
}, new Arr());
}, new ArrayVal());
$this->assertTrue($v->assert('test'));
}
@ -54,7 +54,7 @@ class CallTest extends \PHPUnit_Framework_TestCase
*/
public function testCallbackFailedShouldThrowCallException()
{
$v = new Call('strrev', new Arr());
$v = new Call('strrev', new ArrayVal());
$this->assertFalse($v->validate('test'));
$this->assertFalse($v->assert('test'));
}