Added Exceptions for AlwaysInvalid, AlwaysValid and CountryCode validators

This commit is contained in:
Alexandre Gaigalas 2012-05-24 12:13:48 -03:00
parent dcc94661b2
commit 2858863662
4 changed files with 81 additions and 2 deletions

View file

@ -171,6 +171,8 @@ Reference
* v::callback()
* v::not()
* v::when()
* v::alwaysValid()
* v::alwaysInvalid()
### Comparing Values
@ -250,6 +252,11 @@ Reference
* v::noneOf()
* v::oneOf()
### Regional
* v::tld()
* v::coutryCode()
### Other
* v::cnpj()
@ -261,7 +268,6 @@ Reference
* v::json()
* v::macAddress()
* v::sf()
* v::tld()
* v::zend()
### Alphabetically
@ -352,6 +358,14 @@ See also:
* v::each() - Validates each member of an array
* v::key() - Validates a specific key of an array
### v::alwaysValid
Always returns true.
### v::alwaysInvalid
Always return false.
#### v::attribute($name)
#### v::attribute($name, v $validator)
#### v::attribute($name, v $validator, boolean $mandatory=true)
@ -470,6 +484,16 @@ See also:
* v::call() - A more elaborated building block validator
#### v::countryCode
Validates an ISO country code like US or BR.
v::countryCode('BR'); //true
See also:
* v::tld() - Validates a top level domain
#### v::cnpj()
Validates the Brazillian CNPJ number. Ignores non-digit chars, so
@ -1216,7 +1240,8 @@ Validates a top-level domain
See also
* v::domain()
* v::domain() - Validates domain names
* v::countryCode() - Validates ISO country codes
#### v::uppercase()

View file

@ -0,0 +1,18 @@
<?php
namespace Respect\Validation\Exceptions;
class AlwaysInalidException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} is always invalid',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} is always valid',
)
);
}

View file

@ -0,0 +1,18 @@
<?php
namespace Respect\Validation\Exceptions;
class AlwaysValidException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} is always valid',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} is always invalid',
)
);
}

View file

@ -0,0 +1,18 @@
<?php
namespace Respect\Validation\Exceptions;
class CountryCodeException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a valid country',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid country',
)
);
}