From e708edd005dca48a84eea32fd6f4af3029079582 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Sun, 6 Nov 2016 18:45:44 +0100 Subject: [PATCH] Rename rule "Numeric" to "NumericVal" --- README.md | 2 +- docs/Factor.md | 2 +- docs/Finite.md | 2 +- docs/Infinite.md | 2 +- docs/IntType.md | 2 +- docs/IntVal.md | 2 +- docs/Negative.md | 2 +- docs/{Numeric.md => NumericVal.md} | 8 ++++---- docs/Positive.md | 2 +- docs/README.md | 2 +- docs/VALIDATORS.md | 8 ++++---- ...ericException.php => NumericValException.php} | 2 +- library/Rules/Length.php | 2 +- library/Rules/{Numeric.php => NumericVal.php} | 2 +- library/Validator.php | 2 +- tests/integration/issue-719.phpt | 4 ++-- tests/integration/rules/numeric_1.phpt | 4 ++-- tests/integration/rules/numeric_2.phpt | 8 ++++---- tests/integration/rules/numeric_3.phpt | 8 ++++---- tests/integration/rules/numeric_4.phpt | 8 ++++---- tests/unit/Rules/NotTest.php | 16 ++++++++-------- .../{NumericTest.php => NumericValTest.php} | 10 +++++----- 22 files changed, 50 insertions(+), 50 deletions(-) rename docs/{Numeric.md => NumericVal.md} (57%) rename library/Exceptions/{NumericException.php => NumericValException.php} (91%) rename library/Rules/{Numeric.php => NumericVal.php} (90%) rename tests/unit/Rules/{NumericTest.php => NumericValTest.php} (82%) diff --git a/README.md b/README.md index 047b1158..78ac130f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docs/Factor.md b/docs/Factor.md index 1e042764..5d5a274d 100644 --- a/docs/Factor.md +++ b/docs/Factor.md @@ -16,4 +16,4 @@ See also: * [Digit](Digit.md) * [Finite](Finite.md) * [Infinite](Infinite.md) - * [Numeric](Numeric.md) + * [NumericVal](NumericVal.md) diff --git a/docs/Finite.md b/docs/Finite.md index 42ef9f30..4bb7069e 100644 --- a/docs/Finite.md +++ b/docs/Finite.md @@ -15,4 +15,4 @@ See also: * [Digit](Digit.md) * [Infinite](Infinite.md) * [IntVal](IntVal.md) - * [Numeric](Numeric.md) + * [NumericVal](NumericVal.md) diff --git a/docs/Infinite.md b/docs/Infinite.md index d29c666a..7b3d874d 100644 --- a/docs/Infinite.md +++ b/docs/Infinite.md @@ -14,4 +14,4 @@ See also: * [Digit](Digit.md) * [Finite](Finite.md) * [IntVal](IntVal.md) - * [Numeric](Numeric.md) + * [NumericVal](NumericVal.md) diff --git a/docs/IntType.md b/docs/IntType.md index d4313657..94d05f49 100644 --- a/docs/IntType.md +++ b/docs/IntType.md @@ -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) diff --git a/docs/IntVal.md b/docs/IntVal.md index 18a04046..e96e1a22 100644 --- a/docs/IntVal.md +++ b/docs/IntVal.md @@ -15,4 +15,4 @@ See also: * [Digit](Digit.md) * [Finite](Finite.md) * [Infinite](Infinite.md) - * [Numeric](Numeric.md) + * [NumericVal](NumericVal.md) diff --git a/docs/Negative.md b/docs/Negative.md index efecb520..18b2c40b 100644 --- a/docs/Negative.md +++ b/docs/Negative.md @@ -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 ``` *** diff --git a/docs/Numeric.md b/docs/NumericVal.md similarity index 57% rename from docs/Numeric.md rename to docs/NumericVal.md index d8121fb6..d9c2f64d 100644 --- a/docs/Numeric.md +++ b/docs/NumericVal.md @@ -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 ``` *** diff --git a/docs/Positive.md b/docs/Positive.md index ecf75d9f..9f172eb5 100644 --- a/docs/Positive.md +++ b/docs/Positive.md @@ -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 ``` *** diff --git a/docs/README.md b/docs/README.md index 9f30bd1b..dccf8b5f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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 diff --git a/docs/VALIDATORS.md b/docs/VALIDATORS.md index 7222a953..316d9706 100644 --- a/docs/VALIDATORS.md +++ b/docs/VALIDATORS.md @@ -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) diff --git a/library/Exceptions/NumericException.php b/library/Exceptions/NumericValException.php similarity index 91% rename from library/Exceptions/NumericException.php rename to library/Exceptions/NumericValException.php index 538620f5..26518e77 100644 --- a/library/Exceptions/NumericException.php +++ b/library/Exceptions/NumericValException.php @@ -11,7 +11,7 @@ namespace Respect\Validation\Exceptions; -class NumericException extends ValidationException +class NumericValException extends ValidationException { public static $defaultTemplates = [ self::MODE_DEFAULT => [ diff --git a/library/Rules/Length.php b/library/Rules/Length.php index 27764e21..8e05cd48 100644 --- a/library/Rules/Length.php +++ b/library/Rules/Length.php @@ -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) diff --git a/library/Rules/Numeric.php b/library/Rules/NumericVal.php similarity index 90% rename from library/Rules/Numeric.php rename to library/Rules/NumericVal.php index 990d0449..ad2684b8 100644 --- a/library/Rules/Numeric.php +++ b/library/Rules/NumericVal.php @@ -11,7 +11,7 @@ namespace Respect\Validation\Rules; -class Numeric extends AbstractRule +class NumericVal extends AbstractRule { public function validate($input) { diff --git a/library/Validator.php b/library/Validator.php index e78f7557..40e13959 100644 --- a/library/Validator.php +++ b/library/Validator.php @@ -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() diff --git a/tests/integration/issue-719.phpt b/tests/integration/issue-719.phpt index 3a2e3156..b886eff4 100644 --- a/tests/integration/issue-719.phpt +++ b/tests/integration/issue-719.phpt @@ -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'), ]; diff --git a/tests/integration/rules/numeric_1.phpt b/tests/integration/rules/numeric_1.phpt index 505a218e..33c0cbbd 100644 --- a/tests/integration/rules/numeric_1.phpt +++ b/tests/integration/rules/numeric_1.phpt @@ -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-- \ No newline at end of file diff --git a/tests/integration/rules/numeric_2.phpt b/tests/integration/rules/numeric_2.phpt index 550b8dd8..c316023d 100644 --- a/tests/integration/rules/numeric_2.phpt +++ b/tests/integration/rules/numeric_2.phpt @@ -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; } diff --git a/tests/integration/rules/numeric_3.phpt b/tests/integration/rules/numeric_3.phpt index d3caa6fe..0a62044b 100644 --- a/tests/integration/rules/numeric_3.phpt +++ b/tests/integration/rules/numeric_3.phpt @@ -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; } diff --git a/tests/integration/rules/numeric_4.phpt b/tests/integration/rules/numeric_4.phpt index 6ff8ab95..beab6dad 100644 --- a/tests/integration/rules/numeric_4.phpt +++ b/tests/integration/rules/numeric_4.phpt @@ -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; } diff --git a/tests/unit/Rules/NotTest.php b/tests/unit/Rules/NotTest.php index 13411da4..9dc7140b 100644 --- a/tests/unit/Rules/NotTest.php +++ b/tests/unit/Rules/NotTest.php @@ -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())], ]; } } diff --git a/tests/unit/Rules/NumericTest.php b/tests/unit/Rules/NumericValTest.php similarity index 82% rename from tests/unit/Rules/NumericTest.php rename to tests/unit/Rules/NumericValTest.php index ff05d7ba..a73b3fd3 100644 --- a/tests/unit/Rules/NumericTest.php +++ b/tests/unit/Rules/NumericValTest.php @@ -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) {