mirror of
https://github.com/Respect/Validation.git
synced 2024-06-20 14:35:06 +02:00
Rename rule "Cntrl" to "Control"
This commit will rename the rule by removing the abbreviation to make it a bit easier to understand what it does and much easier to find. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
4db2b00f6c
commit
9c0f8dcfcc
|
@ -207,7 +207,7 @@
|
|||
- [Alpha](rules/Alpha.md)
|
||||
- [Base64](rules/Base64.md)
|
||||
- [Charset](rules/Charset.md)
|
||||
- [Cntrl](rules/Cntrl.md)
|
||||
- [Control](rules/Control.md)
|
||||
- [Consonant](rules/Consonant.md)
|
||||
- [Contains](rules/Contains.md)
|
||||
- [ContainsAny](rules/ContainsAny.md)
|
||||
|
@ -290,7 +290,7 @@
|
|||
- [Charset](rules/Charset.md)
|
||||
- [Cnh](rules/Cnh.md)
|
||||
- [Cnpj](rules/Cnpj.md)
|
||||
- [Cntrl](rules/Cntrl.md)
|
||||
- [Control](rules/Control.md)
|
||||
- [Consonant](rules/Consonant.md)
|
||||
- [Contains](rules/Contains.md)
|
||||
- [ContainsAny](rules/ContainsAny.md)
|
||||
|
|
|
@ -42,7 +42,7 @@ See also:
|
|||
|
||||
- [Alpha](Alpha.md)
|
||||
- [Charset](Charset.md)
|
||||
- [Cntrl](Cntrl.md)
|
||||
- [Control](Control.md)
|
||||
- [Consonant](Consonant.md)
|
||||
- [Digit](Digit.md)
|
||||
- [Lowercase](Lowercase.md)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# Cntrl
|
||||
# Control
|
||||
|
||||
- `Cntrl()`
|
||||
- `Cntrl(string ...$additionalChars)`
|
||||
- `Control()`
|
||||
- `Control(string ...$additionalChars)`
|
||||
|
||||
Validates if all of the characters in the provided string, are control
|
||||
characters.
|
||||
|
||||
```php
|
||||
v::cntrl()->validate("\n\r\t"); // true
|
||||
v::control()->validate("\n\r\t"); // true
|
||||
```
|
||||
|
||||
## Categorization
|
||||
|
@ -18,6 +18,7 @@ v::cntrl()->validate("\n\r\t"); // true
|
|||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.0.0 | Renamed from `Cntrl` to `Control`
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
|
@ -22,6 +22,6 @@ Version | Description
|
|||
***
|
||||
See also:
|
||||
|
||||
- [Cntrl](Cntrl.md)
|
||||
- [Control](Control.md)
|
||||
- [Graph](Graph.md)
|
||||
- [Punct](Punct.md)
|
||||
|
|
|
@ -22,6 +22,6 @@ Version | Description
|
|||
***
|
||||
See also:
|
||||
|
||||
- [Cntrl](Cntrl.md)
|
||||
- [Control](Control.md)
|
||||
- [Graph](Graph.md)
|
||||
- [Printable](Printable.md)
|
||||
|
|
|
@ -22,4 +22,4 @@ Version | Description
|
|||
***
|
||||
See also:
|
||||
|
||||
- [Cntrl](Cntrl.md)
|
||||
- [Control](Control.md)
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Respect\Validation\Exceptions;
|
|||
* @author Danilo Correa <danilosilva87@gmail.com>
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
final class CntrlException extends FilteredValidationException
|
||||
final class ControlException extends FilteredValidationException
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
|
@ -23,7 +23,7 @@ use function ctype_cntrl;
|
|||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
* @author Nick Lombard <github@jigsoft.co.za>
|
||||
*/
|
||||
final class Cntrl extends AbstractFilterRule
|
||||
final class Control extends AbstractFilterRule
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
|
@ -45,7 +45,7 @@ use function count;
|
|||
* @method static Validator charset(string ...$charset)
|
||||
* @method static Validator cnh()
|
||||
* @method static Validator cnpj()
|
||||
* @method static Validator cntrl(string ...$additionalChars)
|
||||
* @method static Validator control(string ...$additionalChars)
|
||||
* @method static Validator consonant(string ...$additionalChars)
|
||||
* @method static Validator contains($containsValue, bool $identical = false)
|
||||
* @method static Validator containsAny(array $needles, bool $strictCompareArray = false)
|
||||
|
|
|
@ -7,54 +7,54 @@ declare(strict_types=1);
|
|||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CntrlException;
|
||||
use Respect\Validation\Exceptions\ControlException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::cntrl()->check('16-50');
|
||||
} catch (CntrlException $exception) {
|
||||
v::control()->check('16-50');
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::cntrl('16')->check('16-50');
|
||||
} catch (CntrlException $exception) {
|
||||
v::control('16')->check('16-50');
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cntrl())->check("\n");
|
||||
} catch (CntrlException $exception) {
|
||||
v::not(v::control())->check("\n");
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cntrl('16'))->check("16\n");
|
||||
} catch (CntrlException $exception) {
|
||||
v::not(v::control('16'))->check("16\n");
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::cntrl()->assert('Foo');
|
||||
v::control()->assert('Foo');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::cntrl('Bar')->assert('Foo');
|
||||
v::control('Bar')->assert('Foo');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cntrl())->assert("\n");
|
||||
v::not(v::control())->assert("\n");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cntrl('Bar'))->assert("Bar\n");
|
||||
v::not(v::control('Bar'))->assert("Bar\n");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage().PHP_EOL;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use stdClass;
|
|||
* @group rule
|
||||
*
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Cntrl
|
||||
* @covers \Respect\Validation\Rules\Control
|
||||
*
|
||||
* @author Andre Ramaciotti <andre@ramaciotti.com>
|
||||
* @author Gabriel Caruso <carusogabriel34@gmail.com>
|
||||
|
@ -28,22 +28,22 @@ use stdClass;
|
|||
* @author Nick Lombard <github@jigsoft.co.za>
|
||||
* @author Pascal Borreli <pascal@borreli.com>
|
||||
*/
|
||||
final class CntrlTest extends RuleTestCase
|
||||
final class ControlTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function providerForValidInput(): array
|
||||
{
|
||||
$cntrl = new Cntrl();
|
||||
$sut = new Control();
|
||||
|
||||
return [
|
||||
'\n' => [$cntrl, "\n"],
|
||||
'\r' => [$cntrl, "\r"],
|
||||
'\t' => [$cntrl, "\t"],
|
||||
'\n\r\t' => [$cntrl, "\n\r\t"],
|
||||
'Ignoring all characters' => [new Cntrl('!@#$%^&*(){} '), '!@#$%^&*(){} '],
|
||||
'Ignoring some characters' => [new Cntrl('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"],
|
||||
'\n' => [$sut, "\n"],
|
||||
'\r' => [$sut, "\r"],
|
||||
'\t' => [$sut, "\t"],
|
||||
'\n\r\t' => [$sut, "\n\r\t"],
|
||||
'Ignoring all characters' => [new Control('!@#$%^&*(){} '), '!@#$%^&*(){} '],
|
||||
'Ignoring some characters' => [new Control('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -52,20 +52,20 @@ final class CntrlTest extends RuleTestCase
|
|||
*/
|
||||
public function providerForInvalidInput(): array
|
||||
{
|
||||
$cntrl = new Cntrl();
|
||||
$sut = new Control();
|
||||
|
||||
return [
|
||||
'empty parameter' => [$cntrl, ''],
|
||||
'16-50' => [$cntrl, '16-50'],
|
||||
'a' => [$cntrl, 'a'],
|
||||
'white space' => [$cntrl, ' '],
|
||||
'Foo' => [$cntrl, 'Foo'],
|
||||
'12.1' => [$cntrl, '12.1'],
|
||||
'"-12"' => [$cntrl, '-12'],
|
||||
'-12' => [$cntrl, -12],
|
||||
'alganet' => [$cntrl, 'alganet'],
|
||||
'empty array parameter' => [$cntrl, []],
|
||||
'object' => [$cntrl, new stdClass()],
|
||||
'empty parameter' => [$sut, ''],
|
||||
'16-50' => [$sut, '16-50'],
|
||||
'a' => [$sut, 'a'],
|
||||
'white space' => [$sut, ' '],
|
||||
'Foo' => [$sut, 'Foo'],
|
||||
'12.1' => [$sut, '12.1'],
|
||||
'"-12"' => [$sut, '-12'],
|
||||
'-12' => [$sut, -12],
|
||||
'alganet' => [$sut, 'alganet'],
|
||||
'empty array parameter' => [$sut, []],
|
||||
'object' => [$sut, new stdClass()],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue