Permalink
Browse files

Split Validate/Validate_AR

  • Loading branch information...
1 parent 9f22b5f commit 8b7aca9c0914ef2953e94ac5eb5040b6c2b88b9f @CloCkWeRX CloCkWeRX committed Nov 26, 2011
Showing with 0 additions and 311 deletions.
  1. +0 −115 Validate/AR.php
  2. +0 −62 package_AR.xml
  3. +0 −49 tests/validate_AR_postal_code.phpt
  4. +0 −85 tests/validate_AR_region.phpt
View
@@ -1,115 +0,0 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-/**
- * Specific validation methods for data used in Argentina
- *
- * This source file is subject to the New BSD license, That is bundled
- * with this package in the file LICENSE, and is available through
- * the world-wide-web at
- * http://www.opensource.org/licenses/bsd-license.php
- * If you did not receive a copy of the new BSDlicense and are unable
- * to obtain it through the world-wide-web, please send a note to
- * pajoye@php.net so we can mail you a copy immediately.
- *
- * PHP Versions 4 and 5
- *
- * @category Validate
- * @package Validate_AR
- * @author Marcelo Santos Araujo <msaraujo@php.net>
- * @author David Coallier <davidc@php.net>
- * @copyright 1997-2005 Marcelo Santos Araujo
- * @license http://www.opensource.org/licenses/bsd-license.php new BSD
- * @version CVS: $Id$
- * @link http://pear.php.net/package/Validate_AR
- */
-
-/**
- * Data validation class for Argentina
- *
- * This class provides methods to validate:
- * - Postal code CPA (Código Postal Argentino)
- * - Regions - provinces of Argentina
- *
- * @category Validate
- * @package Validate_AR
- * @author Marcelo Santos Araujo <msaraujo@php.net>
- * @author David Coallier <davidc@php.net>
- * @copyright 1997-2005 Marcelo Santos Araujo
- * @license http://www.opensource.org/licenses/bsd-license.php new BSD
- * @version Release: @package_version@
- * @link http://pear.php.net/package/Validate_AR
- */
-class Validate_AR
-{
- /**
- * Validate CPA (Código Postal Argentino, like postcode in US
- * and other languages)
- * format: one letter [B-T],four digits and three letters
- *
- * @param string $postalCode AR CPA/postalCode to validate
- * @param bool $strong optional; checks (e.g. against a list of postcodes)
- * (not implemented)
- * @param bool $casesens optional; (true - case sensitive, false - not case
- * sensitive)
- *
- * @return bool true if CPA is ok, false otherwise
- *
- * @link http://en.wikipedia.org/wiki/Postal_codes_in_Argentina
- * @link http://www.correoargentino.com.ar/consulta_cpa/cons_.php
- */
- function postalCode($postalCode, $strong = false, $casesens = true)
- {
- if (strlen($postalCode) == 8) {
- $regexp = $casesens ? '/^[B-T]\d{4}[A-Z]{3}$/' : '/^[B-T]\d{4}[A-Z]{3}$/i';
- return (bool) preg_match($regexp, $postalCode);
- } elseif (strlen($postalCode) == 5) {
- $regexp = $casesens ? '/^[B-T]\d{4}$/' : '/^[B-T]\d{4}$/i';
- return (bool) preg_match($regexp, $postalCode);
- } elseif (strlen($postalCode) == 4) {
- return (bool) preg_match('/^\d{4}$/', $postalCode);
- } else {
- return false;
- }
- }
-
- /**
- * Validates a "region" (i.e. province) code
- *
- * @param string $region 2-letter state code
- *
- * @return bool true if $region is ok, false otherwise
- * @static
- */
- function region($region)
- {
- switch (strtoupper($region)) {
- case 'BA':
- case 'CC':
- case 'CT':
- case 'CH':
- case 'DF':
- case 'CB':
- case 'CN':
- case 'ER':
- case 'FM':
- case 'JY':
- case 'LP':
- case 'LR':
- case 'MZ':
- case 'MN':
- case 'NQ':
- case 'RN':
- case 'SA':
- case 'SJ':
- case 'SL':
- case 'SC':
- case 'SF':
- case 'SE':
- case 'TF':
- case 'TM':
- return true;
- }
- return false;
- }
-}
-?>
View
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.8.0alpha1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
- <name>Validate_AR</name>
- <channel>pear.php.net</channel>
- <summary>Validation class for Argentina</summary>
- <description>Package contains locale validation for Argentina such as:
- * Postal Code
- * Region (provinces)
-
- </description>
- <lead>
- <name>Marcelo Santos Araujo</name>
- <user>msaraujo</user>
- <email>msaraujo@php.net</email>
- <active>yes</active>
- </lead>
- <lead>
- <name>David Coallier</name>
- <user>davidc</user>
- <email>davidc@php.net</email>
- <active>yes</active>
- </lead>
- <date>2009-03-21</date>
- <time>23:43:45</time>
- <version>
- <release>0.1.1</release>
- <api>0.1.0</api>
- </version>
- <stability>
- <release>alpha</release>
- <api>alpha</api>
- </stability>
- <license>New BSD</license>
- <notes>
-QA release
-Bug #17654 postalCode does not return boolean but integer
-</notes>
- <contents>
- <dir baseinstalldir="/" name="/">
- <dir name="Validate">
- <file name="AR.php" role="php" />
- </dir> <!-- //Validate -->
- <file name="LICENSE" role="doc" />
- <file name="tests/validate_AR_postal_code.phpt" role="test" />
- <file name="tests/validate_AR_region.phpt" role="test" />
- </dir> <!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>4.2.0</min>
- </php>
- <pearinstaller>
- <min>1.6.1</min>
- </pearinstaller>
- </required>
- </dependencies>
- <phprelease />
-</package>
@@ -1,49 +0,0 @@
---TEST--
-validate_AR_post_code.phpt: Unit tests for postalCode method 'Validate/AR.php'
-
---FILE--
-<?php
-// Validate test script
-$noYes = array('NO', 'YES');
-if (is_file(dirname(__FILE__) . '/../Validate/AR.php')) {
- require_once dirname(__FILE__) . '/../Validate/AR.php';
-} else {
- require_once 'Validate/AR.php';
-}
-
-echo "Test Validate_AR\n";
-echo "****************\n";
-
-//test passport
-$codes = array(
-'B1234ABC', //OK
-'T2345BCD', //OK
-'A1234ABC', //NOK
-'U1234ABC', //NOK
-'U123AB', //NOK
-'U1234ABCD', //NOK
-'b1234abc', //NOK
-'1234', //OK
-'B1234'//OK
-);
-echo "\nTest Postal Codes\n";
-foreach ($codes as $code) {
- echo "{$code}: ".$noYes[Validate_AR::postalCode($code, false, true)]."\n";
-}
-exit(0);
-?>
-
---EXPECT--
-Test Validate_AR
-****************
-
-Test Postal Codes
-B1234ABC: YES
-T2345BCD: YES
-A1234ABC: NO
-U1234ABC: NO
-U123AB: NO
-U1234ABCD: NO
-b1234abc: NO
-1234: YES
-B1234: YES
@@ -1,85 +0,0 @@
---TEST--
-validate_AR_post_code.phpt: Unit tests for region method 'Validate/AR.php'
-
---FILE--
-<?php
-// Validate test script
-$noYes = array('NO', 'YES');
-if (is_file(dirname(__FILE__) . '/../Validate/AR.php')) {
- require_once dirname(__FILE__) . '/../Validate/AR.php';
-} else {
- require_once 'Validate/AR.php';
-}
-
-echo "Test Validate_AR\n";
-echo "****************\n";
-
-//test passport
-$codes = array(
-'BA',
-'CC',
-'CT',
-'CH',
-'DF',
-'CB',
-'CN',
-'ER',
-'FM',
-'JY',
-'LP',
-'LR',
-'MZ',
-'MN',
-'NQ',
-'RN',
-'SA',
-'SJ',
-'SL',
-'SC',
-'SF',
-'SE',
-'TF',
-'TM',
-'AA', //NOK
-'ZA', //NOK
-'EG' //NOK
-);
-echo "\nTest Region Code\n";
-foreach ($codes as $code) {
- echo "{$code}: ".$noYes[Validate_AR::region($code)]."\n";
-}
-exit(0);
-?>
-
---EXPECT--
-Test Validate_AR
-****************
-
-Test Region Code
-BA: YES
-CC: YES
-CT: YES
-CH: YES
-DF: YES
-CB: YES
-CN: YES
-ER: YES
-FM: YES
-JY: YES
-LP: YES
-LR: YES
-MZ: YES
-MN: YES
-NQ: YES
-RN: YES
-SA: YES
-SJ: YES
-SL: YES
-SC: YES
-SF: YES
-SE: YES
-TF: YES
-TM: YES
-AA: NO
-ZA: NO
-EG: NO

0 comments on commit 8b7aca9

Please sign in to comment.