cvs: pear /Validate package.xml /Validate/Validate NL.php
| From: | Dave Mertens | Date: | Mon, 06 Oct 2003 21:26:25 +0000 |
| Subject: | cvs: pear /Validate package.xml /Validate/Validate NL.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13450@lists.php.net to get a copy of this message | ||
zyprexia Mon Oct 6 17:26:25 2003 EDT
Added files:
/pear/Validate/Validate NL.php
Modified files:
/pear/Validate package.xml
Log:
Added some Dutch validation checks
- postcode
support several formats such as '1234 AB' and '1234AB' where lowercase
letters are allowed (1234ab)
- phonenumber
with type checking:
- normal (vaste KPN net) (mobilenumbers not allowed)
- mobile (only mobile numbers are allowed)
- any (both normal and mobile numbers)
Internatinal number format is also supported (0031, +31).
Check is based on last 9 digits (so anything before is ignored)
- Social security check (SoFi nummer)
At some later point also bankaccount number check (both bank as Postbank)
Index: pear/Validate/package.xml
diff -u pear/Validate/package.xml:1.11 pear/Validate/package.xml:1.12
--- pear/Validate/package.xml:1.11 Tue Mar 11 20:29:06 2003
+++ pear/Validate/package.xml Mon Oct 6 17:26:24 2003
@@ -37,12 +37,20 @@
<name>Brent Cook</name>
<email>busterb@mail.utexas.edu</email>
</maintainer>
+ <maintainer>
+ <user>zyprexia</user>
+ <role>contributor</role>
+ <name>Dave Mertens</name>
+ <email>zyprexia@php.net</email>
+ </maintainer>
</maintainers>
<release>
- <version>0.1.1</version>
+ <version>0.1.2</version>
<state>alpha</state>
- <date>2003-03-12</date>
- <notes>Validate::date(); argument parsing fixed</notes>
+ <date>2003-??-??</date>
+ <notes>
+ - Added some dutch validations
+ </notes>
<filelist>
<dir name="/">
<file role="php">Validate.php</file>
@@ -51,6 +59,7 @@
<file role="php">US.php</file>
<file role="php">FR.php</file>
<file role="php">UK.php</file>
+ <file role="php">NL.php</file>
</dir>
<dir name="tests" role="test">
<file>number.php</file>
@@ -66,4 +75,12 @@
<dep type="php" rel="ge" version="4.1.0" />
</deps>
</release>
+ <changelog>
+ <release>
+ <version>0.1.1</version>
+ <state>alpha</state>
+ <date>2003-03-12</date>
+ <notes>Validate::date(); argument parsing fixed</notes>
+ </release>
+ </changelog>
</package>
Index: pear/Validate/Validate/NL.php
+++ pear/Validate/Validate/NL.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 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.
|
// | 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. |
// +----------------------------------------------------------------------+
// | Authors: Dave Mertens <zyprexia@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: NL.php,v 1.1 2003/10/06 21:26:25 zyprexia Exp $
//
// Specific validation methods for data used in NL
//
require_once('Validate.php');
define( "PHONENUMBER_TYPE_ANY", 0); //Any dutch phonenumber
define( "PHONENUMBER_TYPE_NORMAL", 1); //only normal phonenumber (mobile numers are
not allowed)
define( "PHONENUMBER_TYPE_MOBILE", 2); //only mobile numbers are allowed
class Validate_NL
{
/**
* Validate a NL postcode
*
* @param string $postcode NL postcode to validate
* @return bool true if postcode is ok, false otherwise
*/
function postcode($postcode)
{
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)
* @param int $type Type of phonenumber to check
* @return bool true if (phone) number is correct
*/
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)
{
case PHONENUMBER_TYPE_ANY:
$result = true; //we have a 9 digit numeric number.
break;
case PHONENUMBER_TYPE_NORMAL:
if ((int)$number[0] != 6)
$result = true; //normal phonenumbers don't begin with 6
(00316, +316 and 06 are reserved for mobile numbers)
break;
case PHONENUMBER_TYPE_MOBILE:
if ((int)$number[0] == 6)
$result = true; //mobilenumbers start with a 6
break;
}
}
}
return $result;
}
/**
* Social Security Number check (very simple, just a 9 digit number..)
* In Dutch SoFi (Sociaal Fiscaal) nummer
*
* @param string $number Dutch social security number
* @return bool true if SSN number is correct
*/
function SSN($number)
{
return (ereg("^[0-9]{9}$", $number));
}
}
?>