mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 16:22:16 +02:00
Rename rule "Bool" to "BoolType"
This commit is contained in:
parent
937fa6b183
commit
0ae5d25de7
10
docs/Bool.md
10
docs/Bool.md
|
@ -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
10
docs/BoolType.md
Normal 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
|
||||
```
|
|
@ -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
|
||||
```
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
class BoolException extends ValidationException
|
||||
class BoolTypeException extends ValidationException
|
||||
{
|
||||
public static $defaultTemplates = array(
|
||||
self::MODE_DEFAULT => array(
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class Bool extends AbstractRule
|
||||
class BoolType extends AbstractRule
|
||||
{
|
||||
public function validate($input)
|
||||
{
|
|
@ -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)
|
||||
|
|
|
@ -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));
|
Loading…
Reference in a new issue