From bc98f09e4eac649f6b36d87573ca53cee8bb5fb3 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:54 -0300 Subject: [PATCH] Create "EcSubdivisionCode" rule --- .../EcSubdivisionCodeException.php | 31 +++++++++++ .../SubdivisionCode/EcSubdivisionCode.php | 53 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/EcSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/EcSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/EcSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/EcSubdivisionCodeException.php new file mode 100644 index 00000000..37663be5 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/EcSubdivisionCodeException.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the "LICENSE.md" + * file that was distributed with this source code. + */ + +namespace Respect\Validation\Exceptions\SubdivisionCode; + +use Respect\Validation\Exceptions\SubdivisionCodeException; + +/** + * Exception class for Ecuador subdivision code. + * + * ISO 3166-1 alpha-2: EC + */ +class EcSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Ecuador', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Ecuador', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/EcSubdivisionCode.php b/library/Rules/SubdivisionCode/EcSubdivisionCode.php new file mode 100644 index 00000000..e56a7497 --- /dev/null +++ b/library/Rules/SubdivisionCode/EcSubdivisionCode.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the "LICENSE.md" + * file that was distributed with this source code. + */ + +namespace Respect\Validation\Rules\SubdivisionCode; + +use Respect\Validation\Rules\AbstractSearcher; + +/** + * Validator for Ecuador subdivision code. + * + * ISO 3166-1 alpha-2: EC + * + * @link http://www.geonames.org/EC/administrative-division-ecuador.html + */ +class EcSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'A', // Azuay + 'B', // Bolivar + 'C', // Carchi + 'D', // Orellana + 'E', // Esmeraldas + 'F', // Canar + 'G', // Guayas + 'H', // Chimborazo + 'I', // Imbabura + 'L', // Loja + 'M', // Manabi + 'N', // Napo + 'O', // El Oro + 'P', // Pichincha + 'R', // Los Rios + 'S', // Morona-Santiago + 'SD', // Santo Domingo de los Tsáchilas + 'SE', // Santa Elena + 'T', // Tungurahua + 'U', // Sucumbios + 'W', // Galapagos + 'X', // Cotopaxi + 'Y', // Pastaza + 'Z', // Zamora-Chinchipe + ); + + public $compareIdentical = true; +}