Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Alnum
  • Alpha
  • Cp
  • Date
  • Digit
  • Email
  • Equal
  • Interval
  • Time
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * Pry Framework
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file LICENSE.txt.
10:  * 
11:  */
12: 
13: namespace Pry\Validate\Validator;
14: 
15: use Pry\Validate\ValidateAbstract;
16: 
17: /**
18:  * Validateur de code postal Français. Prend en charge les codes postaux corse.
19:  * @category Pry
20:  * @package Validate
21:  * @subpackage Validate_Validator
22:  * @version 1.0.0 
23:  * @author Olivier ROGER <oroger.fr>
24:  */
25: class Cp extends ValidateAbstract
26: {
27: 
28:     /**
29:      * Constructeur
30:      * @access public
31:      */
32:     public function __construct()
33:     {
34:         $this->errorMsg = "n'est pas un code postal valide";
35:     }
36: 
37:     /**
38:      * Validation
39:      *
40:      * @param string $string Elément à valider
41:      * @return boolean
42:      */
43:     public function isValid($string)
44:     {
45:         $string  = $this->cleanString((string) $string);
46:         $pattern = '`^(2[ab]|0[1-9]|[1-9][0-9])[0-9]{3}$`';
47:         if (preg_match($pattern, $string))
48:             return true;
49:         return false;
50:     }
51: 
52: }
Pry API documentation generated by ApiGen 2.8.0