Rename rule "Numeric" to "NumericVal"

This commit is contained in:
Henrique Moody 2016-11-06 18:45:44 +01:00
parent 07a120d058
commit e708edd005
No known key found for this signature in database
GPG key ID: 221E9281655813A6
22 changed files with 50 additions and 50 deletions

View file

@ -9,7 +9,7 @@
[The most awesome validation engine ever created for PHP.](http://bit.ly/1a1oeQv)
- Complex rules made simple: `v::numeric()->positive()->between(1, 255)->validate($input)`.
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->validate($input)`.
- [Granularity control](docs/README.md#validation-methods) for advanced reporting.
- More than 100 (fully tested) validators.
- [A concrete API](docs/CONCRETE_API.md) for non fluent usage.

View file

@ -16,4 +16,4 @@ See also:
* [Digit](Digit.md)
* [Finite](Finite.md)
* [Infinite](Infinite.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)

View file

@ -15,4 +15,4 @@ See also:
* [Digit](Digit.md)
* [Infinite](Infinite.md)
* [IntVal](IntVal.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)

View file

@ -14,4 +14,4 @@ See also:
* [Digit](Digit.md)
* [Finite](Finite.md)
* [IntVal](IntVal.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)

View file

@ -20,7 +20,7 @@ See also:
* [Infinite](Infinite.md)
* [IntVal](IntVal.md)
* [NullType](NullType.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)
* [ObjectType](ObjectType.md)
* [ResourceType](ResourceType.md)
* [StringType](StringType.md)

View file

@ -15,4 +15,4 @@ See also:
* [Digit](Digit.md)
* [Finite](Finite.md)
* [Infinite](Infinite.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)

View file

@ -5,7 +5,7 @@
Validates if a number is lower than zero
```php
v::numeric()->negative()->validate(-15); // true
v::numericVal()->negative()->validate(-15); // true
```
***

View file

@ -1,12 +1,12 @@
# Numeric
# NumericVal
- `v::numeric()`
- `v::numericVal()`
Validates on any numeric value.
```php
v::numeric()->validate(-12); // true
v::numeric()->validate('135.0'); // true
v::numericVal()->validate(-12); // true
v::numericVal()->validate('135.0'); // true
```
***

View file

@ -5,7 +5,7 @@
Validates if a number is higher than zero
```php
v::numeric()->positive()->validate(-15); // false
v::numericVal()->positive()->validate(-15); // false
```
***

View file

@ -15,7 +15,7 @@ The Hello World validator is something like this:
```php
$number = 123;
v::numeric()->validate($number); // true
v::numericVal()->validate($number); // true
```
## Chained validation

View file

@ -17,7 +17,7 @@
* [IntType](IntType.md)
* [IterableType](IterableType.md)
* [NullType](NullType.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)
* [ObjectType](ObjectType.md)
* [ResourceType](ResourceType.md)
* [ScalarVal](ScalarVal.md)
@ -47,7 +47,7 @@
* [Max](Max.md)
* [Min](Min.md)
## Numeric
## NumericVal
* [Between](Between.md)
* [BoolType](BoolType.md)
@ -63,7 +63,7 @@
* [Multiple](Multiple.md)
* [Negative](Negative.md)
* [NotEmpty](NotEmpty.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)
* [Odd](Odd.md)
* [PerfectSquare](PerfectSquare.md)
* [Positive](Positive.md)
@ -289,7 +289,7 @@
* [NotEmpty](NotEmpty.md)
* [NotOptional](NotOptional.md)
* [NullType](NullType.md)
* [Numeric](Numeric.md)
* [NumericVal](NumericVal.md)
* [ObjectType](ObjectType.md)
* [Odd](Odd.md)
* [OneOf](OneOf.md)

View file

@ -11,7 +11,7 @@
namespace Respect\Validation\Exceptions;
class NumericException extends ValidationException
class NumericValException extends ValidationException
{
public static $defaultTemplates = [
self::MODE_DEFAULT => [

View file

@ -24,7 +24,7 @@ class Length extends AbstractRule
$this->minValue = $min;
$this->maxValue = $max;
$this->inclusive = $inclusive;
$paramValidator = new OneOf(new Numeric(), new NullType());
$paramValidator = new OneOf(new NumericVal(), new NullType());
if (!$paramValidator->validate($min)) {
throw new ComponentException(
sprintf('%s is not a valid numeric length', $min)

View file

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

View file

@ -109,7 +109,7 @@ use Respect\Validation\Rules\Key;
* @method static Validator notOptional()
* @method static Validator noWhitespace()
* @method static Validator nullType()
* @method static Validator numeric()
* @method static Validator numericVal()
* @method static Validator objectType()
* @method static Validator odd()
* @method static Validator oneOf()

View file

@ -13,8 +13,8 @@ $input = [
];
$rules = [
v::key('user_name', v::numeric())->setName('First Name'),
v::key('user_surname', v::numeric())->setName('Second Name'),
v::key('user_name', v::numericVal())->setName('First Name'),
v::key('user_surname', v::numericVal())->setName('Second Name'),
v::key('user_tel', v::phone())->setName('Phone number'),
];

View file

@ -4,8 +4,8 @@ require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
v::numeric()->assert(123);
v::numeric()->check(123);
v::numericVal()->assert(123);
v::numericVal()->check(123);
?>
--EXPECTF--

View file

@ -3,17 +3,17 @@
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\AllOfException;
use Respect\Validation\Exceptions\NumericException;
use Respect\Validation\Exceptions\NumericValException;
use Respect\Validation\Validator as v;
try {
v::numeric()->check('a');
} catch (NumericException $e) {
v::numericVal()->check('a');
} catch (NumericValException $e) {
echo $e->getMainMessage().PHP_EOL;
}
try {
v::numeric()->assert('a');
v::numericVal()->assert('a');
} catch (AllOfException $e) {
echo $e->getFullMessage().PHP_EOL;
}

View file

@ -3,17 +3,17 @@
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\AllOfException;
use Respect\Validation\Exceptions\NumericException;
use Respect\Validation\Exceptions\NumericValException;
use Respect\Validation\Validator as v;
try {
v::numeric()->setName('Field')->check(null);
} catch (NumericException $e) {
v::numericVal()->setName('Field')->check(null);
} catch (NumericValException $e) {
echo $e->getMainMessage().PHP_EOL;
}
try {
v::numeric()->setName('Field')->assert('');
v::numericVal()->setName('Field')->assert('');
} catch (AllOfException $e) {
echo $e->getFullMessage().PHP_EOL;
}

View file

@ -3,17 +3,17 @@
require 'vendor/autoload.php';
use Respect\Validation\Exceptions\AllOfException;
use Respect\Validation\Exceptions\NumericException;
use Respect\Validation\Exceptions\NumericValException;
use Respect\Validation\Validator as v;
try {
v::not(v::numeric())->check('1');
} catch (NumericException $e) {
v::not(v::numericVal())->check('1');
} catch (NumericValException $e) {
echo $e->getMainMessage().PHP_EOL;
}
try {
v::not(v::numeric())->assert('1');
v::not(v::numericVal())->assert('1');
} catch (AllOfException $e) {
echo $e->getFullMessage().PHP_EOL;
}

View file

@ -59,9 +59,9 @@ class NotTest extends \PHPUnit_Framework_TestCase
[new AllOf(new NoWhitespace(), new Digit()), 'as df'],
[new AllOf(new NoWhitespace(), new Digit()), '12 34'],
[new AllOf(new AllOf(new NoWhitespace(), new Digit())), '12 34'],
[new AllOf(new NoneOf(new Numeric(), new IntVal())), 13.37],
[new NoneOf(new Numeric(), new IntVal()), 13.37],
[Validator::noneOf(Validator::numeric(), Validator::intVal()), 13.37],
[new AllOf(new NoneOf(new NumericVal(), new IntVal())), 13.37],
[new NoneOf(new NumericVal(), new IntVal()), 13.37],
[Validator::noneOf(Validator::numericVal(), Validator::intVal()), 13.37],
];
}
@ -69,9 +69,9 @@ class NotTest extends \PHPUnit_Framework_TestCase
{
return [
[new IntVal(), 123],
[new AllOf(new OneOf(new Numeric(), new IntVal())), 13.37],
[new OneOf(new Numeric(), new IntVal()), 13.37],
[Validator::oneOf(Validator::numeric(), Validator::intVal()), 13.37],
[new AllOf(new OneOf(new NumericVal(), new IntVal())), 13.37],
[new OneOf(new NumericVal(), new IntVal()), 13.37],
[Validator::oneOf(Validator::numericVal(), Validator::intVal()), 13.37],
];
}
@ -79,10 +79,10 @@ class NotTest extends \PHPUnit_Framework_TestCase
{
return [
[new IntVal()],
[new AllOf(new Numeric(), new IntVal())],
[new AllOf(new NumericVal(), new IntVal())],
[new Not(new Not(new IntVal()))],
[Validator::intVal()->setName('Bar')],
[Validator::noneOf(Validator::numeric(), Validator::intVal())],
[Validator::noneOf(Validator::numericVal(), Validator::intVal())],
];
}
}

View file

@ -13,16 +13,16 @@ namespace Respect\Validation\Rules;
/**
* @group rule
* @covers Respect\Validation\Rules\Numeric
* @covers Respect\Validation\Exceptions\NumericException
* @covers Respect\Validation\Rules\NumericVal
* @covers Respect\Validation\Exceptions\NumericValException
*/
class NumericTest extends \PHPUnit_Framework_TestCase
class NumericValTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected function setUp()
{
$this->object = new Numeric();
$this->object = new NumericVal();
}
/**
@ -37,7 +37,7 @@ class NumericTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider providerForNotNumeric
* @expectedException Respect\Validation\Exceptions\NumericException
* @expectedException Respect\Validation\Exceptions\NumericValException
*/
public function testNotNumeric($input)
{