From 1c1a130b03c933bfc08cc83fd6874edd4cd558f6 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:51 -0300 Subject: [PATCH] Create "TlSubdivisionCode" rule --- .../TlSubdivisionCodeException.php | 31 ++++++++++++++ .../SubdivisionCode/TlSubdivisionCode.php | 42 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/TlSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/TlSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/TlSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/TlSubdivisionCodeException.php new file mode 100644 index 00000000..49834196 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/TlSubdivisionCodeException.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 East Timor subdivision code. + * + * ISO 3166-1 alpha-2: TL + */ +class TlSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of East Timor', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of East Timor', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/TlSubdivisionCode.php b/library/Rules/SubdivisionCode/TlSubdivisionCode.php new file mode 100644 index 00000000..8a97d0c4 --- /dev/null +++ b/library/Rules/SubdivisionCode/TlSubdivisionCode.php @@ -0,0 +1,42 @@ + + * + * 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 East Timor subdivision code. + * + * ISO 3166-1 alpha-2: TL + * + * @link http://www.geonames.org/TL/administrative-division-east-timor.html + */ +class TlSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'AL', // Aileu + 'AN', // Ainaro + 'BA', // Baucau + 'BO', // Bobonaro + 'CO', // Cova Lima + 'DI', // Dili + 'ER', // Ermera + 'LA', // Lautem + 'LI', // Liquica + 'MF', // Manufahi + 'MT', // Manatuto + 'OE', // Oecussi + 'VI', // Viqueque + ); + + public $compareIdentical = true; +}