root/trunk/patForms/Rule/GermanZipCode.php

Revision 251, 1.3 kB (checked in by argh, 3 years ago)

Added french translations

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * patForms Rule German Zip Code
4  *
5  * $Id$
6  *
7  * @package        patForms
8  * @subpackage    Rules
9  */
10
11 /**
12  * patForms Rule German Zip Code
13  *
14  * This only checks for the format of a german zip code.
15  *
16  * @package        patForms
17  * @subpackage    Rules
18  * @author        Stephan Schmidt <schst@php-tools.net>
19  * @license        LGPL, see license.txt for details
20  * @link        http://www.php-tools.net
21  */
22 class patForms_Rule_GermanZipCode extends patForms_Rule
23 {
24    /**
25     * name of the rule
26     *
27     * @abstract
28     * @access    private
29     */
30     var    $ruleName = 'GermanZipCode';
31
32    /**
33     * define error codes and messages for the rule
34     *
35     * @access    private
36     * @var        array    $validatorErrorCodes
37     * @todo     translate error messages
38     */
39     var    $validatorErrorCodes  =   array(
40         "C"    =>    array(
41             1    =>    "The value is not a german zip code.",
42         ),
43         "de" =>    array(
44             1    =>    "Der Wert ist keine deutsche Postleitzahl.",
45         ),
46         "fr" =>    array(
47             1    =>    "La valeur entrĂ©e n'est pas un code postal allemand valide.",
48         )
49     );
50
51    /**
52     * method called by patForms or any patForms_Element to validate the
53     * element or the form.
54     *
55     * @access    public
56     * @param    object patForms    form object
57     */
58     function applyRule( &$element, $type = PATFORMS_RULE_BEFORE_VALIDATION )
59     {
60         if (preg_match('/[0-9]{5}/', $element->getValue())) {
61             return true;
62         }
63         $this->addValidationError( 1 );
64         return false;   
65     }
66 }
67 ?>
Note: See TracBrowser for help on using the browser.