From fc780a63752dc703a3d679420b7e1bd86b47101b Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:47 -0300 Subject: [PATCH] Create "SrSubdivisionCode" rule --- .../SrSubdivisionCodeException.php | 31 +++++++++++++++ .../SubdivisionCode/SrSubdivisionCode.php | 39 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/SrSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/SrSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/SrSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/SrSubdivisionCodeException.php new file mode 100644 index 00000000..fb2a805d --- /dev/null +++ b/library/Exceptions/SubdivisionCode/SrSubdivisionCodeException.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 Suriname subdivision code. + * + * ISO 3166-1 alpha-2: SR + */ +class SrSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Suriname', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Suriname', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/SrSubdivisionCode.php b/library/Rules/SubdivisionCode/SrSubdivisionCode.php new file mode 100644 index 00000000..346f3ed2 --- /dev/null +++ b/library/Rules/SubdivisionCode/SrSubdivisionCode.php @@ -0,0 +1,39 @@ + + * + * 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 Suriname subdivision code. + * + * ISO 3166-1 alpha-2: SR + * + * @link http://www.geonames.org/SR/administrative-division-suriname.html + */ +class SrSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'BR', // Brokopondo + 'CM', // Commewijne + 'CR', // Coronie + 'MA', // Marowijne + 'NI', // Nickerie + 'PM', // Paramaribo + 'PR', // Para + 'SA', // Saramacca + 'SI', // Sipaliwini + 'WA', // Wanica + ); + + public $compareIdentical = true; +}