cvs: pear /Validate/Validate AT.php DE.php ES.php FR.php Finance.php NL.php PL.php UK.php US.php pt_BR.php /Validate/Validate/Finance IBAN.php

From: Date: Wed, 10 Dec 2003 15:07:35 +0000
Subject: cvs: pear /Validate/Validate AT.php DE.php ES.php FR.php Finance.php NL.php PL.php UK.php US.php pt_BR.php /Validate/Validate/Finance IBAN.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-14759@lists.php.net to get a copy of this message
pajoye Wed Dec 10 10:07:35 2003 EDT Removed files: /pear/Validate/Validate pt_BR.php Modified files: /pear/Validate/Validate AT.php DE.php ES.php FR.php Finance.php NL.php PL.php UK.php US.php /pear/Validate/Validate/Finance IBAN.php Log: - remove pt_BR.php, moved to ptBR.php to allow multiple support

Index: pear/Validate/Validate/AT.php diff -u pear/Validate/Validate/AT.php:1.1 pear/Validate/Validate/AT.php:1.2 --- pear/Validate/Validate/AT.php:1.1 Tue Dec 9 12:33:35 2003 +++ pear/Validate/Validate/AT.php Wed Dec 10 10:07:34 2003 @@ -1,17 +1,21 @@ <?php // +----------------------------------------------------------------------+ -// | PEAR :: Validate :: AT | +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 3.0 of the PHP license, | -// | that is available at http://www.php.net/license/3_0.txt | -// | If you did not receive a copy of the PHP license and are unable | -// | to obtain it through the world-wide-web, please send a note to | +// | that is bundled with this package in the file LICENSE, and is | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Copyright (c) 2003 Michael Wallner <mike@iworks.at> | // +----------------------------------------------------------------------+ // -// $Id: AT.php,v 1.1 2003/12/09 17:33:35 pajoye Exp $ +// $Id: AT.php,v 1.2 2003/12/10 15:07:34 pajoye Exp $ /** * Requires Validate @@ -25,7 +29,7 @@ * @package Validate * @category PHP * -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ class Validate_AT Index: pear/Validate/Validate/DE.php diff -u pear/Validate/Validate/DE.php:1.1 pear/Validate/Validate/DE.php:1.2 --- pear/Validate/Validate/DE.php:1.1 Tue Dec 9 10:38:14 2003 +++ pear/Validate/Validate/DE.php Wed Dec 10 10:07:34 2003 @@ -5,15 +5,16 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// +// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> | +// +----------------------------------------------------------------------+ // // Specific validation methods for data used in DE // Index: pear/Validate/Validate/ES.php diff -u pear/Validate/Validate/ES.php:1.7 pear/Validate/Validate/ES.php:1.8 --- pear/Validate/Validate/ES.php:1.7 Mon Feb 17 06:05:51 2003 +++ pear/Validate/Validate/ES.php Wed Dec 10 10:07:34 2003 @@ -5,10 +5,10 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Authors: Tomas V.V.Cox <cox@idecnet.com> | // +----------------------------------------------------------------------+ // -// $Id: ES.php,v 1.7 2003/02/17 11:05:51 mansion Exp $ +// $Id: ES.php,v 1.8 2003/12/10 15:07:34 pajoye Exp $ // // Specific validation methods for data used in Spain // Index: pear/Validate/Validate/FR.php diff -u pear/Validate/Validate/FR.php:1.8 pear/Validate/Validate/FR.php:1.9 --- pear/Validate/Validate/FR.php:1.8 Mon Feb 17 05:56:41 2003 +++ pear/Validate/Validate/FR.php Wed Dec 10 10:07:34 2003 @@ -5,10 +5,10 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Authors: Pierre-Alain Joye <paj@pearfr.org> | // +----------------------------------------------------------------------+ // -// $Id: FR.php,v 1.8 2003/02/17 10:56:41 mansion Exp $ +// $Id: FR.php,v 1.9 2003/12/10 15:07:34 pajoye Exp $ // // Specific validation methods for data used in France Index: pear/Validate/Validate/Finance.php diff -u pear/Validate/Validate/Finance.php:1.3 pear/Validate/Validate/Finance.php:1.4 --- pear/Validate/Validate/Finance.php:1.3 Mon Aug 18 05:10:11 2003 +++ pear/Validate/Validate/Finance.php Wed Dec 10 10:07:34 2003 @@ -1,14 +1,14 @@ <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ -// | PHP version 4.0 | +// | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> | // +----------------------------------------------------------------------+ // -// $Id: Finance.php,v 1.3 2003/08/18 09:10:11 neufeind Exp $ +// $Id: Finance.php,v 1.4 2003/12/10 15:07:34 pajoye Exp $ require_once('Validate/Finance/IBAN.php'); Index: pear/Validate/Validate/NL.php diff -u pear/Validate/Validate/NL.php:1.5 pear/Validate/Validate/NL.php:1.6 --- pear/Validate/Validate/NL.php:1.5 Wed Oct 15 05:26:39 2003 +++ pear/Validate/Validate/NL.php Wed Dec 10 10:07:34 2003 @@ -5,10 +5,10 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Authors: Dave Mertens <zyprexia@php.net> | // +----------------------------------------------------------------------+ // -// $Id: NL.php,v 1.5 2003/10/15 09:26:39 zyprexia Exp $ +// $Id: NL.php,v 1.6 2003/12/10 15:07:34 pajoye Exp $ // // Specific validation methods for data used in NL // @@ -39,10 +39,10 @@ { return (ereg('^[0-9]{4}\ {0,1}[A-Za-z]{2}$', $postcode)); // '1234 AB', '1234AB', '1234 ab' } - - - - /** + + + + /** * Validate a phonenumber * * @param string $number Dutch phonenumber (can be in international format (eg +31 or 0031) @@ -52,14 +52,14 @@ function phonenumber($number, $type = PHONENUMBER_TYPE_ANY) { $result = false; - + //we need at least 9 digits if (ereg("^[+0-9]{9,}$", $number)) { $number = substr($number, strlen($number)-9); - + //we only use the last 9 digits (so no troubles with international numbers) if (strlen($number) >= 9) { - switch ($type) + switch ($type) { case VALIDATE_NL_PHONENUMBER_TYPE_ANY: $result = true; //we have a 9 digit numeric number. @@ -78,8 +78,8 @@ return $result; } - - + + /** * Social Security Number check (very simple, just a 9 digit number..) * In Dutch SoFi (Sociaal Fiscaal) nummer @@ -89,10 +89,10 @@ */ function SSN($number) { - return (ereg("^[0-9]{9}$", $number)); + return (ereg("^[0-9]{9}$", $number)); } - - /** + + /** * Bankaccount validation check (based on 11proef) * * @param string $number Dutch bankaccount number @@ -102,7 +102,7 @@ { $result = false; //by default we return false $checksum = 0; - + if (is_numeric((string)$number) && strlen((string)$number) <= 10) { $number = str_pad($number, 10, '0', STR_PAD_LEFT); //make sure we have a 10 digit number @@ -110,15 +110,15 @@ for ($i=0; $i < 10; $i++) { $checksum += ( (int)$number[$i] * (10 - $i) ); } - + //Banknumber is 'correct' if we can divide checksum by 11 if ($checksum > 0 && $checksum % 11 == 0) $result = true; - + //return result return $result; } } - + } ?> Index: pear/Validate/Validate/PL.php diff -u pear/Validate/Validate/PL.php:1.1 pear/Validate/Validate/PL.php:1.2 --- pear/Validate/Validate/PL.php:1.1 Tue Dec 9 10:37:02 2003 +++ pear/Validate/Validate/PL.php Wed Dec 10 10:07:34 2003 @@ -5,10 +5,10 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: PL.php,v 1.1 2003/12/09 15:37:02 pajoye Exp $ +// $Id: PL.php,v 1.2 2003/12/10 15:07:34 pajoye Exp $ // // Specific validation methods for data used in Poland // @@ -25,7 +25,7 @@ { /** * Validates NIP (Polish tax identification number) - * + * * Sprawdza NIP (Numer Identyfikacji Podatkowej) * http://chemeng.p.lodz.pl/zylla/ut/nip-rego.html * http://www.republika.pl/stepa/cyfra2.htm @@ -52,7 +52,7 @@ /** * Validates bank number (Polish banks) - * + * * @param string $number 8-digit number to validate * @returns bool * @author Piotr Klaban <makler@man.torun.pl> @@ -75,7 +75,7 @@ /** * Validates PESEL (Polish human identification number) - * + * * Sprawdza PESEL (Powszechny Elektroniczny System Ewidencji Ludno¶ci) * http://www.mswia.gov.pl/crp_pesel.html * NOTE: some people can have the same PESEL, and some can have @@ -108,7 +108,7 @@ $vy = substr($pesel,0,2); $vm = substr($pesel,2,2); $vd = substr($pesel,4,2); - + // decode century if ($vm < 20) $vy += 1900; @@ -132,7 +132,7 @@ /** * Validates REGON (Polish statistical national economy register) - * + * * Sprawdza REGON (Rejestr Gospodarki Narodowej) * http://chemeng.p.lodz.pl/zylla/ut/nip-rego.html * Index: pear/Validate/Validate/UK.php diff -u pear/Validate/Validate/UK.php:1.5 pear/Validate/Validate/UK.php:1.6 --- pear/Validate/Validate/UK.php:1.5 Mon Feb 17 06:03:22 2003 +++ pear/Validate/Validate/UK.php Wed Dec 10 10:07:34 2003 @@ -5,10 +5,10 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Authors: Pierre-Alain Joye <paj@pearfr.org> | // +----------------------------------------------------------------------+ // -// $Id: UK.php,v 1.5 2003/02/17 11:03:22 mansion Exp $ +// $Id: UK.php,v 1.6 2003/12/10 15:07:34 pajoye Exp $ // // Specific validation methods for data used in UK // @@ -25,15 +25,164 @@ class Validate_UK { + // overlay function + function getZipValFunc(){ + return 'postcode'; + } + /** + * validates a standard uk postcode + * + * + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $postcode the postcode to be validated + * @return bool + */ + function postcode($postcode){ + // remove spaces and uppercase it + $postcode = strtoupper(str_replace(' ', '', $postcode)); + + $preg = "/^[A-Z]{1,2}[0-9]{1,2}[A-Z]?[0-9]{1,2}[A-Z]{2}/"; + $match = (preg_match($preg, $postcode))? true : false; + return $match; + } + + /** + * validates a National Insurance Number (ssn equiv) + * + * + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $ni NI number + * @return bool + */ + function ni($ni){ + $ni = strtoupper(str_replace(' ', '', $ni)); + $preg = "/^[A-Z]{2}[0-9]{6}[ABCDEFT]/"; + $match = (preg_match($preg, $ni))? true : false; + return $match; + } + + /** + * Validates a sort code, must be passed with dashes in the right places + * + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $sc the sort code + * @return bool + * @see + */ + function sortCode($sc){ + // must be in format nn-nn-nn (must contain dashes) + // need to research the range of values - i have assumed 00-00-00 to 99-99-99 + // but it might be something like 01-01-01 to 50-99-99 + $preg = "/[0-9]{2}\-[0-9]{2}\-[0-9]{2}/"; + $match = (preg_match($preg, $sc))? true : false; + return $match; + } + /** - * Validate a UK postcode + * Validates a bank ac number + * do not use - it is too basic at the moment * - * @param string $postcode UK postcode to validate - * @return bool true if postcode is ok, false otherwise + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $ac + * @return bool */ - function postcode($postcode) - { - return (ereg('^[A-Z]{1, 2}[0-9]{1, 2}[A-Z]{0, 1} [0-9][A-Z]{2}$', $postcode)); + function bankAC($ac){ + // just checking to see if it is 6-8 digits + // *THIS IS PROBABLY WRONG!!! RESEARCH* + $preg = "/[0-9]{6,8}/"; + $match = (preg_match($preg, $sc))? true : false; + return $match; + } + + /** + * Checks that the entry is a number starting with 0 of the right length + * + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $tel the tel number + * @return bool + * @see + */ + function tel($tel){ + // just checks to see if it is numeric and starts with a 0 + // remove any wierd characters like (,),-,. etc + $tel = str_replace(Array('(', ')', '-', '+', '.', ' '), '', $tel); + $preg = "/^0[0-9]{8,10}/"; + $match = (preg_match($preg, $tel))? true : false; + return $match; + } + + /** + * Validates a car registration number + * + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $reg the registration number + * @return bool + */ + function carReg($reg){ + // checks for valid car licence plate + // need to extend to include v old plates (without year prefix/suffix) + // extend to reject invalid year letters (eg Z) + // remove any spaces + $reg = strtoupper(str_replace(' ', '', $reg)); + // suffixed year letter + $suffpreg = "/[A-Z]{3}[0-9]{1,3}[A-Z]/"; + $suffres = preg_match($suffpreg, $reg); + // prefixed year letter + $prepreg = "/[A-Z][0-9]{1,3}[A-Z]{3}/"; + $suffres = preg_match($prepreg, $reg); + // new ones + $newpreg = "/[A-Z][0-9][05][A-Z]{3}/"; + $suffres = preg_match($newpreg, $reg); + if (!$suffres||!$preres&&!$newres){ + return false; + } else { + return true; + } + } + + /** + * + * Validates a UK passport number, EU might be the same + * just checks for 9 digits mine starts 00 and i have included that - might cause problems + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $ + * @param string $name + * @return string + */ + function passport($pp){ + // just checks for 9 digit number + $preg = "/[0-9]{9}/"; + $match = (preg_match($preg, $pp))? true : false ; + return $match; + } + + /** + * Validates a UK driving licence + * + * + * @access public + * @author Michael Dransfield <mikeNO@SPAMblueroot.net> + * @param string $dl + * @return bool + */ + function drive($dl){ + $preg = "[A-Z]{5}[0-9]{6}[A-Z0-9]{5}"; + $match = (preg_match($preg, $dl))? true : false; + return $match; } } + ?> \ No newline at end of file Index: pear/Validate/Validate/US.php diff -u pear/Validate/Validate/US.php:1.9 pear/Validate/Validate/US.php:1.10 --- pear/Validate/Validate/US.php:1.9 Sun Feb 16 23:25:35 2003 +++ pear/Validate/Validate/US.php Wed Dec 10 10:07:34 2003 @@ -5,10 +5,10 @@ // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -17,7 +17,7 @@ // | Tim Gallagher <timg@sunflowerroad.com> | // +----------------------------------------------------------------------+ // -// $Id: US.php,v 1.9 2003/02/17 04:25:35 pajoye Exp $ +// $Id: US.php,v 1.10 2003/12/10 15:07:34 pajoye Exp $ // // Specific validation methods for data used in the United States // Index: pear/Validate/Validate/Finance/IBAN.php diff -u pear/Validate/Validate/Finance/IBAN.php:1.5 pear/Validate/Validate/Finance/IBAN.php:1.6 --- pear/Validate/Validate/Finance/IBAN.php:1.5 Thu Sep 25 05:57:35 2003 +++ pear/Validate/Validate/Finance/IBAN.php Wed Dec 10 10:07:34 2003 @@ -1,14 +1,14 @@ <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ -// | PHP version 4.0 | +// | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | +// | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | +// | available through the world-wide-web at the following url: | +// | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ // | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> | // +----------------------------------------------------------------------+ // -// $Id: IBAN.php,v 1.5 2003/09/25 09:57:35 neufeind Exp $ +// $Id: IBAN.php,v 1.6 2003/12/10 15:07:34 pajoye Exp $ $GLOBALS['VALIDATE_FINANCE_IBAN_COUNTRYCODES'] = array( @@ -77,7 +77,7 @@ 'SE' => 24, 'SI' => 19 ); - + /** * List of where the bankcode inside an IBAN starts (starting from 0) and its length * @var array
« previous php.pear.cvs (#14759) next »