From 411cb5215d9b2ba6f9aac17dd6d9970fd44656ee Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 21 Sep 2015 13:27:45 -0300 Subject: [PATCH] Create "SlSubdivisionCode" rule --- .../SlSubdivisionCodeException.php | 31 +++++++++++++++++ .../SubdivisionCode/SlSubdivisionCode.php | 33 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 library/Exceptions/SubdivisionCode/SlSubdivisionCodeException.php create mode 100644 library/Rules/SubdivisionCode/SlSubdivisionCode.php diff --git a/library/Exceptions/SubdivisionCode/SlSubdivisionCodeException.php b/library/Exceptions/SubdivisionCode/SlSubdivisionCodeException.php new file mode 100644 index 00000000..75d46f76 --- /dev/null +++ b/library/Exceptions/SubdivisionCode/SlSubdivisionCodeException.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 Sierra Leone subdivision code. + * + * ISO 3166-1 alpha-2: SL + */ +class SlSubdivisionCodeException extends SubdivisionCodeException +{ + public static $defaultTemplates = array( + self::MODE_DEFAULT => array( + self::STANDARD => '{{name}} must be a subdivision code of Sierra Leone', + ), + self::MODE_NEGATIVE => array( + self::STANDARD => '{{name}} must not be a subdivision code of Sierra Leone', + ), + ); +} diff --git a/library/Rules/SubdivisionCode/SlSubdivisionCode.php b/library/Rules/SubdivisionCode/SlSubdivisionCode.php new file mode 100644 index 00000000..d4a49b94 --- /dev/null +++ b/library/Rules/SubdivisionCode/SlSubdivisionCode.php @@ -0,0 +1,33 @@ + + * + * 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 Sierra Leone subdivision code. + * + * ISO 3166-1 alpha-2: SL + * + * @link http://www.geonames.org/SL/administrative-division-sierra-leone.html + */ +class SlSubdivisionCode extends AbstractSearcher +{ + public $haystack = array( + 'E', // Eastern + 'N', // Northern + 'S', // Southern + 'W', // Western + ); + + public $compareIdentical = true; +}