| 1 |
lars |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
/**
|
|
|
4 |
* Methods for common German data validations
|
|
|
5 |
*
|
|
|
6 |
* PHP Versions 4 and 5
|
|
|
7 |
*
|
|
|
8 |
* This source file is subject to the New BSD license, That is bundled
|
|
|
9 |
* with this package in the file LICENSE, and is available through
|
|
|
10 |
* the world-wide-web at
|
|
|
11 |
* http://www.opensource.org/licenses/bsd-license.php
|
|
|
12 |
* If you did not receive a copy of the new BSDlicense and are unable
|
|
|
13 |
* to obtain it through the world-wide-web, please send a note to
|
|
|
14 |
* pajoye@php.net so we can mail you a copy immediately.
|
|
|
15 |
*
|
|
|
16 |
* @category Validate
|
|
|
17 |
* @package Validate_DE
|
|
|
18 |
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
|
|
|
19 |
* @copyright 1997-2005 Stefan Neufeind
|
|
|
20 |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
|
|
21 |
* @version CVS: $Id: DE.php 242590 2007-09-16 17:35:37Z kguest $
|
|
|
22 |
* @link http://pear.php.net/package/Validate_DE
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Data validation class for Germany
|
|
|
27 |
*
|
|
|
28 |
* This class provides methods to validate:
|
|
|
29 |
* - Postal code
|
|
|
30 |
* - German bank code
|
|
|
31 |
*
|
|
|
32 |
* @category Validate
|
|
|
33 |
* @package Validate_DE
|
|
|
34 |
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
|
|
|
35 |
* @copyright 1997-2005 Stefan Neufeind
|
|
|
36 |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
|
|
37 |
* @version Release: @package_version@
|
|
|
38 |
* @link http://pear.php.net/package/Validate_DE
|
|
|
39 |
*/
|
|
|
40 |
class Validate_DE
|
|
|
41 |
{
|
|
|
42 |
/**
|
|
|
43 |
* Validate a German postcode
|
|
|
44 |
*
|
|
|
45 |
* @param string $postcode postcode to validate
|
|
|
46 |
* @param bool $strong optional; strong checks (e.g. against a list of
|
|
|
47 |
* postcodes) (not implemented)
|
|
|
48 |
*
|
|
|
49 |
* @return bool true if postcode is ok, false otherwise
|
|
|
50 |
*/
|
|
|
51 |
function postalCode($postcode, $strong = false)
|
|
|
52 |
{
|
|
|
53 |
// $strong is not used here at the moment; added for API compatibility
|
|
|
54 |
// checks might be added at a later stage
|
|
|
55 |
|
|
|
56 |
return (bool)ereg('^[0-9]{5}$', $postcode);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Validate a German bankcode
|
|
|
61 |
*
|
|
|
62 |
* German bankcodes consist of exactly 8 numbers
|
|
|
63 |
*
|
|
|
64 |
* @param string $bankcode German bankcode to validate
|
|
|
65 |
*
|
|
|
66 |
* @return bool true if bankcode is ok, false otherwise
|
|
|
67 |
*/
|
|
|
68 |
function bankcode($bankcode)
|
|
|
69 |
{
|
|
|
70 |
return (bool)ereg('^[0-9]{8}$', $bankcode);
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
?>
|