Rename rule "Bool" to "BoolType"

This commit is contained in:
Henrique Moody 2015-10-07 11:30:29 -03:00
parent 937fa6b183
commit 0ae5d25de7
9 changed files with 26 additions and 26 deletions

View file

@ -1,10 +0,0 @@
# Bool
- `v::bool()`
Validates if the input is a boolean value:
```php
v::bool()->validate(true); //true
v::bool()->validate(false); //true
```

10
docs/BoolType.md Normal file
View file

@ -0,0 +1,10 @@
# BoolType
- `v::boolType()`
Validates if the input is a boolean value:
```php
v::boolType()->validate(true); //true
v::boolType()->validate(false); //true
```

View file

@ -28,7 +28,7 @@ $dict = array('foo' => 42, 'bar' => 'String');
v::keySet(
v::key('foo', v::int()),
v::key('bar', v::string()),
v::key('baz', v::bool())
v::key('baz', v::boolType())
)->validate($dict); //false
```
@ -39,7 +39,7 @@ $dict = array('foo' => 42, 'bar' => 'String');
v::keySet(
v::key('foo', v::int()),
v::key('bar', v::string()),
v::key('baz', v::bool(), false)
v::key('baz', v::boolType(), false)
)->validate($dict); //true
```

View file

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

View file

@ -3,7 +3,7 @@
## Types
* [Arr](Arr.md)
* [Bool](Bool.md)
* [BoolType](BoolType.md)
* [CallableType](CallableType.md)
* [Date](Date.md)
* [False](False.md)
@ -43,7 +43,7 @@
## Numeric
* [Between](Between.md)
* [Bool](Bool.md)
* [BoolType](BoolType.md)
* [Even](Even.md)
* [Factor](Factor.md)
* [Finite](Finite.md)
@ -188,7 +188,7 @@
* [BankAccount](BankAccount.md)
* [Between](Between.md)
* [Bic](Bic.md)
* [Bool](Bool.md)
* [BoolType](BoolType.md)
* [Call](Call.md)
* [CallableType](CallableType.md)
* [Callback](Callback.md)

View file

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

View file

@ -11,7 +11,7 @@
namespace Respect\Validation\Rules;
class Bool extends AbstractRule
class BoolType extends AbstractRule
{
public function validate($input)
{

View file

@ -31,7 +31,7 @@ use Respect\Validation\Rules\Key;
* @method static Validator base()
* @method static Validator between(mixed $min = null, mixed $max = null, bool $inclusive = false)
* @method static Validator bic(string $countryCode)
* @method static Validator bool()
* @method static Validator boolType()
* @method static Validator call()
* @method static Validator callableType()
* @method static Validator callback(mixed $callback)

View file

@ -13,14 +13,14 @@ namespace Respect\Validation\Rules;
/**
* @group rule
* @covers Respect\Validation\Rules\Bool
* @covers Respect\Validation\Exceptions\BoolException
* @covers Respect\Validation\Rules\BoolType
* @covers Respect\Validation\Exceptions\BoolTypeException
*/
class BoolTest extends \PHPUnit_Framework_TestCase
class BoolTypeTest extends \PHPUnit_Framework_TestCase
{
public function testBooleanValuesONLYShouldReturnTrue()
{
$validator = new Bool();
$validator = new BoolType();
$this->assertTrue($validator->__invoke(true));
$this->assertTrue($validator->__invoke(false));
$this->assertTrue($validator->assert(true));
@ -30,17 +30,17 @@ class BoolTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException Respect\Validation\Exceptions\BoolException
* @expectedException Respect\Validation\Exceptions\BoolTypeException
*/
public function testInvalidBooleanShouldRaiseException()
{
$validator = new Bool();
$validator = new BoolType();
$this->assertFalse($validator->check('foo'));
}
public function testInvalidBooleanValuesShouldReturnFalse()
{
$validator = new Bool();
$validator = new BoolType();
$this->assertFalse($validator->__invoke(''));
$this->assertFalse($validator->__invoke('foo'));
$this->assertFalse($validator->__invoke(123123));