Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Validate_Validator_Alnum
  • Validate_Validator_Alpha
  • Validate_Validator_Cp
  • Validate_Validator_Date
  • Validate_Validator_Digit
  • Validate_Validator_Email
  • Validate_Validator_Equal
  • Validate_Validator_Interval
  • Validate_Validator_Time
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Pry Framework
 4:  *
 5:  * LICENSE
 6:  *
 7:  * This source file is subject to the new BSD license that is bundled
 8:  * with this package in the file LICENSE.txt.
 9:  * 
10:  * @version $Revision: 276 $
11:  */
12: 
13: /**
14:  * Validateur Alphanuméric
15:  * 
16:  * @category Pry
17:  * @package Validate
18:  * @subpackage Validate_Validator
19:  * @version 1.0.0 
20:  * @author Olivier ROGER <oroger.fr>
21:  */
22: class Validate_Validator_Alnum extends Validate_Abstract
23: {
24: 
25:     /**
26:      * Constructeur. Par défaut autorise les espaces
27:      *
28:      * @param boolean $espace Autorise ou non les espaces dans les chaines
29:      * @access public
30:      */
31:     public function __construct($espace = true)
32:     {
33:         $this->espace = (boolean)$espace;
34:         $this->errorMsg = "n'est pas une valeur alphanumérique";
35:     }
36:     
37:     /**
38:      * Vérifie si $string est alphanumérique
39:      *
40:      * @param string $string
41:      * @return boolean
42:      */
43:     public function isValid($string)
44:     {
45:         $string = $this->cleanString($string);
46:         //On cherche si on ne trouve pas d alnum. Donc si true = la chaine n'est pas alnum on renvoi false.
47:         if($this->espace)
48:             if(preg_match('/[^a-zA-Z0-9\s\-]/',$string))
49:                 return false;
50:             else
51:                 return true;
52:         else
53:             if(preg_match('/[^a-zA-Z0-9\-]/',$string))
54:                 return false;
55:             else
56:                 return true;
57:     }
58: }
59:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1