| 1 |
lars |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +----------------------------------------------------------------------+
|
|
|
4 |
// | Copyright (c) 1997-2005 [Your Name] |
|
|
|
5 |
// +----------------------------------------------------------------------+
|
|
|
6 |
// | This source file is subject to the New BSD license, That is bundled |
|
|
|
7 |
// | with this package in the file LICENSE, and is available through |
|
|
|
8 |
// | the world-wide-web at |
|
|
|
9 |
// | http://www.opensource.org/licenses/bsd-license.php |
|
|
|
10 |
// | If you did not receive a copy of the new BSDlicense and are unable |
|
|
|
11 |
// | to obtain it through the world-wide-web, please send a note to |
|
|
|
12 |
// | pajoye@php.net so we can mail you a copy immediately. |
|
|
|
13 |
// +----------------------------------------------------------------------+
|
|
|
14 |
// | Author: Tomas V.V.Cox <cox@idecnet.com> |
|
|
|
15 |
// | Pierre-Alain Joye <pajoye@php.net> |
|
|
|
16 |
// +----------------------------------------------------------------------+
|
|
|
17 |
//
|
|
|
18 |
/**
|
|
|
19 |
* Specific validation methods for data used in the [LocaleName]
|
|
|
20 |
*
|
|
|
21 |
* @category Validate
|
|
|
22 |
* @package Validate_[LocaleName]
|
|
|
23 |
* @author [Your Name] <example@example.org>
|
|
|
24 |
* @copyright 1997-2005 [Your name]
|
|
|
25 |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
|
|
26 |
* @version CVS: $Id: Example_Locale.php 275351 2009-02-08 13:06:00Z clockwerx $
|
|
|
27 |
* @link http://pear.php.net/package/Validate_[LocaleName]
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Data validation class for the [LocaleName]
|
|
|
32 |
*
|
|
|
33 |
* This class provides methods to validate:
|
|
|
34 |
* - SSN
|
|
|
35 |
* - Postal code
|
|
|
36 |
* - Telephone number
|
|
|
37 |
*
|
|
|
38 |
* @category Validate
|
|
|
39 |
* @package Validate_[LocaleName]
|
|
|
40 |
* @author [Your Name] <example@example.org>
|
|
|
41 |
* @copyright 1997-2005 [Your name]
|
|
|
42 |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
|
|
43 |
* @version Release: @package_version@
|
|
|
44 |
* @link http://pear.php.net/package/Validate_[LocaleName]
|
|
|
45 |
*/
|
|
|
46 |
class Validate_LocaleName
|
|
|
47 |
{
|
|
|
48 |
/**
|
|
|
49 |
* validates a postcode
|
|
|
50 |
*
|
|
|
51 |
* [Further info goes here]
|
|
|
52 |
*
|
|
|
53 |
* @access public
|
|
|
54 |
* @author [Your name] <example@example.org>
|
|
|
55 |
* @param string the postcode to be validated
|
|
|
56 |
* @param bool optional; strong checks (e.g. against a list of postcodes) (not implanted)
|
|
|
57 |
*
|
|
|
58 |
* @return bool true on success false on failure
|
|
|
59 |
*/
|
|
|
60 |
function postalCode($postcode, $strong = false)
|
|
|
61 |
{
|
|
|
62 |
if (ctype_digit($number)) {
|
|
|
63 |
return true;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
return false;
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* Validates a social security number
|
|
|
71 |
*
|
|
|
72 |
* [Further info goes here]
|
|
|
73 |
*
|
|
|
74 |
* @access public
|
|
|
75 |
* @author [Your name] <example@example.org>
|
|
|
76 |
* @param string $ssn SSN
|
|
|
77 |
*
|
|
|
78 |
* @return bool true on success false on failure
|
|
|
79 |
*/
|
|
|
80 |
function ssn($ssn)
|
|
|
81 |
{
|
|
|
82 |
if (ctype_digit($number)) {
|
|
|
83 |
return true;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
return false;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Validate a phone number
|
|
|
91 |
*
|
|
|
92 |
* [Further info goes here]
|
|
|
93 |
*
|
|
|
94 |
* @access public
|
|
|
95 |
* @author [Your name] <example@example.org>
|
|
|
96 |
* @param string $number the tel number
|
|
|
97 |
*
|
|
|
98 |
* @return bool true on success false on failure
|
|
|
99 |
*/
|
|
|
100 |
function phoneNumber($number)
|
|
|
101 |
{
|
|
|
102 |
if (ctype_digit($number)) {
|
|
|
103 |
return true;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
return false;
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
?>
|