From 0b8a2cc28b003a6a4f449008dc610b674834cf12 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:26:38 -0300 Subject: [PATCH] Create "BeSubdivisionCode" rule --- .../BeSubdivisionCodeException.php | 31 +++++++++++++ .../SubdivisionCode/BeSubdivisionCode.php | 43 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/BeSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/BeSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/BeSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/BeSubdivisionCodeException.php new file mode 100644 index 00000000..1438979c --- /dev/null +++ b/library/Exceptions/SubdivisionCode/BeSubdivisionCodeException.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 Belgium subdivision code. + * + * ISO 3166-1 alpha-2: BE + */ +class BeSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Belgium', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Belgium', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/BeSubdivisionCode.php b/library/Rules/SubdivisionCode/BeSubdivisionCode.php new file mode 100644 index 00000000..5d6f8798 --- /dev/null +++ b/library/Rules/SubdivisionCode/BeSubdivisionCode.php @@ -0,0 +1,43 @@ + + * + * 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 Belgium subdivision code. + * + * ISO 3166-1 alpha-2: BE + * + * @link http://www.geonames.org/BE/administrative-division-belgium.html + */ +class BeSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BRU', // Brussels + 'VLG', // Flanders + 'WAL', // Wallonia + 'BRU', // Brussels + 'VAN', // Antwerpen + 'VBR', // Vlaams Brabant + 'VLI', // Limburg + 'VOV', // Oost-Vlaanderen + 'VWV', // West-Vlaanderen + 'WBR', // Brabant Wallon + 'WHT', // Hainaut + 'WLG', // Liege + 'WLX', // Luxembourg + 'WNA', // Namur + ); + + public $compareIdentical = true; +}