mirror of
https://github.com/Respect/Validation.git
synced 2024-06-28 18:20:07 +02:00
Fix:2 for #97 Refactor rename Vowels to Vowel.
As per #97 Plural rules no singular. Vowels to Vowel. Vowelss now a deprecated decorator class of Vowel. Documentation updated.
This commit is contained in:
parent
e82f209ffd
commit
2c9371e048
27
README.md
27
README.md
|
@ -229,7 +229,8 @@ Reference
|
|||
* v::uppercase()
|
||||
* v::uppercase()
|
||||
* v::version()
|
||||
* v::vowels()
|
||||
* v::vowels() *(deprecated)*
|
||||
* v::vowel()
|
||||
* v::xdigits()
|
||||
|
||||
### Arrays
|
||||
|
@ -342,7 +343,7 @@ See also:
|
|||
* v::alpha() - a-Z, empty or whitespace only
|
||||
* v::digit() - 0-9, empty or whitespace only
|
||||
* v::consonant()
|
||||
* v::vowels()
|
||||
* v::vowel()
|
||||
|
||||
#### v::alpha()
|
||||
#### v::alpha(string $additionalChars)
|
||||
|
@ -356,7 +357,7 @@ See also:
|
|||
* v::alnum() - a-z0-9, empty or whitespace only
|
||||
* v::digit() - 0-9, empty or whitespace only
|
||||
* v::consonant()
|
||||
* v::vowels()
|
||||
* v::vowel()
|
||||
|
||||
#### v::arr()
|
||||
|
||||
|
@ -539,7 +540,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::vowels()
|
||||
* v::vowel()
|
||||
|
||||
#### v::contains($value)
|
||||
#### v::contains($value, boolean $identical=false)
|
||||
|
@ -676,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::vowel()
|
||||
* v::consonant()
|
||||
|
||||
#### v::domain()
|
||||
|
@ -1380,11 +1381,21 @@ Validates version numbers using Semantic Versioning.
|
|||
|
||||
v::version()->validate('1.0.0');
|
||||
|
||||
#### v::vowels()
|
||||
#### v::vowels() *(deprecated)*
|
||||
|
||||
Similar to `v::alnum()`. Validates strings that contain only vowels:
|
||||
Validates strings that contains only vowels. It's now deprecated, vowel should be used
|
||||
instead.
|
||||
|
||||
v::vowels()->validate('aei'); //true
|
||||
See also:
|
||||
|
||||
* v::vowel()
|
||||
|
||||
|
||||
#### v::vowel()
|
||||
|
||||
Similar to `v::alnum()`. Validates strings that contains only vowels:
|
||||
|
||||
v::vowel()->validate('aei'); //true
|
||||
|
||||
See also:
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
class VowelsException extends AlphaException
|
||||
class VowelException extends AlphaException
|
||||
{
|
||||
public static $defaultTemplates = array(
|
||||
self::MODE_DEFAULT => array(
|
11
library/Respect/Validation/Rules/Vowel.php
Normal file
11
library/Respect/Validation/Rules/Vowel.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class Vowel extends AbstractRegexRule
|
||||
{
|
||||
protected function getPregFormat()
|
||||
{
|
||||
return '/^(\s|[aeiouAEIOU])*$/';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class Vowels extends AbstractRegexRule
|
||||
class Vowels extends Vowel
|
||||
{
|
||||
protected function getPregFormat()
|
||||
public function __construct()
|
||||
{
|
||||
return '/^(\s|[aeiouAEIOU])*$/';
|
||||
parent::__construct();
|
||||
trigger_error("Use consonant instead.",
|
||||
E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
class VowelsTest extends \PHPUnit_Framework_TestCase
|
||||
class VowelTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerForValidVowels
|
||||
*/
|
||||
public function testValidDataWithVowelsShouldReturnTrue($validVowels, $aditional='')
|
||||
{
|
||||
$validator = new Vowels($aditional);
|
||||
$validator = new Vowel($aditional);
|
||||
$this->assertTrue($validator->validate($validVowels));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForInvalidVowels
|
||||
* @expectedException Respect\Validation\Exceptions\VowelsException
|
||||
* @expectedException Respect\Validation\Exceptions\VowelException
|
||||
*/
|
||||
public function testInvalidVowelsShouldFailAndThrowVowelsException($invalidVowels, $aditional='')
|
||||
public function testInvalidVowelsShouldFailAndThrowVowelException($invalidVowels, $aditional='')
|
||||
{
|
||||
$validator = new Vowels($aditional);
|
||||
$validator = new Vowel($aditional);
|
||||
$this->assertFalse($validator->validate($invalidVowels));
|
||||
$this->assertFalse($validator->assert($invalidVowels));
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class VowelsTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidConstructorParamsShouldThrowComponentExceptionUponInstantiation($aditional)
|
||||
{
|
||||
$validator = new Vowels($aditional);
|
||||
$validator = new Vowel($aditional);
|
||||
}
|
||||
|
||||
public function providerForInvalidParams()
|
Loading…
Reference in a new issue