mirror of
https://github.com/Respect/Validation.git
synced 2024-06-28 18:20:07 +02:00
Fix:1 for #97 Refactor rename Consonants to Consonant.
As per #97 Plural rules no singular. Consonants to Consonant. Consonants now deprecated. Documentation updated.
This commit is contained in:
parent
a4620918ff
commit
625d78bf90
27
README.md
27
README.md
|
@ -207,7 +207,8 @@ Reference
|
|||
* v::alpha()
|
||||
* v::between()
|
||||
* v::charset()
|
||||
* v::consonants()
|
||||
* v::consonants() *(deprecated)*
|
||||
* v::consonant()
|
||||
* v::contains()
|
||||
* v::control()
|
||||
* v::digits() *(deprecated)*
|
||||
|
@ -340,7 +341,7 @@ See also:
|
|||
|
||||
* v::alpha() - a-Z, empty or whitespace only
|
||||
* v::digit() - 0-9, empty or whitespace only
|
||||
* v::consonants()
|
||||
* v::consonant()
|
||||
* v::vowels()
|
||||
|
||||
#### v::alpha()
|
||||
|
@ -354,7 +355,7 @@ See also:
|
|||
|
||||
* v::alnum() - a-z0-9, empty or whitespace only
|
||||
* v::digit() - 0-9, empty or whitespace only
|
||||
* v::consonants()
|
||||
* v::consonant()
|
||||
* v::vowels()
|
||||
|
||||
#### v::arr()
|
||||
|
@ -516,12 +517,22 @@ See also:
|
|||
* v::cpf() - Validates the Brazillian CPF number.
|
||||
* v::cnh() - Validates the Brazillian driver's license.
|
||||
|
||||
#### v::consonants()
|
||||
#### v::consonants(string $additionalChars)
|
||||
#### v::consonants() *(deprecated)*
|
||||
|
||||
Validates strings that contain only consonants. It's now deprecated, consonant should be used
|
||||
instead.
|
||||
|
||||
See also:
|
||||
|
||||
* v::consonant()
|
||||
|
||||
|
||||
#### v::consonant()
|
||||
#### v::consonant(string $additionalChars)
|
||||
|
||||
Similar to `v::alnum()`. Validates strings that contain only consonants:
|
||||
|
||||
v::consonants()->validate('xkcd'); //true
|
||||
v::consonant()->validate('xkcd'); //true
|
||||
|
||||
See also:
|
||||
|
||||
|
@ -666,7 +677,7 @@ See also:
|
|||
* v::alnum() - a-z0-9, empty or whitespace only
|
||||
* v::alpha() - a-Z, empty or whitespace only
|
||||
* v::vowels()
|
||||
* v::consonants()
|
||||
* v::consonant()
|
||||
|
||||
#### v::domain()
|
||||
|
||||
|
@ -1380,7 +1391,7 @@ See also:
|
|||
* v::alnum() - a-z0-9, empty or whitespace only
|
||||
* v::digit() - 0-9, empty or whitespace only
|
||||
* v::alpha() - a-Z, empty or whitespace only
|
||||
* v::consonants()
|
||||
* v::consonant()
|
||||
|
||||
#### v::when(v $if, v $then, v $else)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
class ConsonantsException extends AlphaException
|
||||
class ConsonantException extends AlphaException
|
||||
{
|
||||
public static $defaultTemplates = array(
|
||||
self::MODE_DEFAULT => array(
|
11
library/Respect/Validation/Rules/Consonant.php
Normal file
11
library/Respect/Validation/Rules/Consonant.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class Consonant extends AbstractRegexRule
|
||||
{
|
||||
protected function getPregFormat()
|
||||
{
|
||||
return '/^(\s|[b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z])*$/';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class Consonants extends AbstractRegexRule
|
||||
class Consonants extends Consonant
|
||||
{
|
||||
protected function getPregFormat()
|
||||
public function __construct()
|
||||
{
|
||||
return '/^(\s|[b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z])*$/';
|
||||
parent::__construct();
|
||||
trigger_error("Use consonant instead.",
|
||||
E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class ConsonantsTest extends \PHPUnit_Framework_TestCase
|
||||
class ConsonantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerForValidConsonants
|
||||
*/
|
||||
public function testValidDataWithConsonantsShouldReturnTrue($validConsonants, $aditional='')
|
||||
{
|
||||
$validator = new Consonants($aditional);
|
||||
$validator = new Consonant($aditional);
|
||||
$this->assertTrue($validator->validate($validConsonants));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForInvalidConsonants
|
||||
* @expectedException Respect\Validation\Exceptions\ConsonantsException
|
||||
* @expectedException Respect\Validation\Exceptions\ConsonantException
|
||||
*/
|
||||
public function testInvalidConsonantsShouldFailAndThrowConsonantsException($invalidConsonants, $aditional='')
|
||||
public function testInvalidConsonantsShouldFailAndThrowConsonantException($invalidConsonants, $aditional='')
|
||||
{
|
||||
$validator = new Consonants($aditional);
|
||||
$validator = new Consonant($aditional);
|
||||
$this->assertFalse($validator->validate($invalidConsonants));
|
||||
$this->assertFalse($validator->assert($invalidConsonants));
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class ConsonantsTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidConstructorParamsShouldThrowComponentExceptionUponInstantiation($aditional)
|
||||
{
|
||||
$validator = new Consonants($aditional);
|
||||
$validator = new Consonant($aditional);
|
||||
}
|
||||
|
||||
public function providerForInvalidParams()
|
Loading…
Reference in a new issue