Source for file NL.php
Documentation is available at NL.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
* Specific validation methods for data used in the Netherlands
* This source file is subject to the New BSD license, That is bundled
* with this package in the file LICENSE, and is available through
* 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.
* @author Dave Mertens <zyprexia@php.net>
* @author Pierre-Alain Joye <pajoye@php.net>
* @copyright 1997-2005 Dave Mertens
* @license http://www.opensource.org/licenses/bsd-license.php new BSD
* @version CVS: $Id: NL.php,v 1.18 2007/08/07 22:31:42 kguest Exp $
* @link http://pear.php.net/package/Validate_NL
define('VALIDATE_NL_PHONENUMBER_TYPE_ANY', 0 );
//only normal phonenumber (mobile numers are not allowed)
define('VALIDATE_NL_PHONENUMBER_TYPE_NORMAL', 1 );
//only mobile numbers are allowed
define('VALIDATE_NL_PHONENUMBER_TYPE_MOBILE', 2 );
* Data validation class for the Netherlands
* This class provides methods to validate:
* - Social insurance number (aka SIN)
* @author Dave Mertens <zyprexia@php.net>
* @copyright 1997-2005 Dave Mertens
* @license http://www.opensource.org/licenses/bsd-license.php new BSD
* @version Release: @package_version@
* @link http://pear.php.net/package/Validate_NL
* @param string $postcode NL postcode to validate
* @param bool $strong optional; strong checks (e.g. against a list
* of postcodes) (not implanted)
* @return bool true if postcode is ok, false otherwise
// $strong is not used here at the moment; added for API compatibility
// checks might be added at a later stage
// '1234 AB', '1234AB', '1234 ab'
return (bool) ereg('^[0-9]{4}\ {0,1}[A-Za-z]{2}$', $postcode);
* @param string $number Dutch phonenumber (can be in international format
* @param int $type Type of phonenumber to check
* @return bool true if (phone) number is correct
function phoneNumber($number, $type = PHONENUMBER_TYPE_ANY )
//we need at least 9 digits
if (ereg("^[+0-9]{9,}$", $number)) {
//we only use the last 9 digits (so no troubles with
//we have a 9 digit numeric number.
//normal phonenumbers don't begin with 6 (00316, +316
//and 06 are reserved for mobile numbers)
if ((int) $number[0 ] != 6 )
//mobilenumbers start with a 6
if ((int) $number[0 ] == 6 )
* Social Security Number check (very simple, just a 9 digit number..)
* In Dutch SoFi (Sociaal Fiscaal) nummer
* @param string $ssn Dutch social security number
* @return bool true if SSN number is correct
return (bool) ereg("^[0-9]{9}$", $ssn);
* Bankaccount validation check (based on 11proef)
* @param string $number Dutch bankaccount number
* @return bool true is bankaccount number 'seems' correct
$result = false; //by default we return false
//make sure we have a 10 digit number
$number = str_pad($number, 10 , '0', STR_PAD_LEFT );
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 )
Documentation generated on Mon, 23 Mar 2009 01:00:02 +0000 by phpDocumentor 1.4.2. PEAR Logo Copyright © PHP Group 2004.
|