• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Validate/Alnum.php

00001 <?php
00025 require_once 'Zend/Validate/Abstract.php';
00026 
00033 class Zend_Validate_Alnum extends Zend_Validate_Abstract
00034 {
00035     const INVALID      = 'alnumInvalid';
00036     const NOT_ALNUM    = 'notAlnum';
00037     const STRING_EMPTY = 'stringEmpty';
00038 
00045     public $allowWhiteSpace;
00046 
00052     protected static $_filter = null;
00053 
00059     protected $_messageTemplates = array(
00060         self::INVALID      => "Invalid type given, value should be float, string, or integer",
00061         self::NOT_ALNUM    => "'%value%' has not only alphabetic and digit characters",
00062         self::STRING_EMPTY => "'%value%' is an empty string"
00063     );
00064 
00071     public function __construct($allowWhiteSpace = false)
00072     {
00073         $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
00074     }
00075 
00081     public function getAllowWhiteSpace()
00082     {
00083         return $this->allowWhiteSpace;
00084     }
00085 
00092     public function setAllowWhiteSpace($allowWhiteSpace)
00093     {
00094         $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
00095         return $this;
00096     }
00097 
00106     public function isValid($value)
00107     {
00108         if (!is_string($value) && !is_int($value) && !is_float($value)) {
00109             $this->_error(self::INVALID);
00110             return false;
00111         }
00112 
00113         $this->_setValue($value);
00114 
00115         if ('' === $value) {
00116             $this->_error(self::STRING_EMPTY);
00117             return false;
00118         }
00119 
00120         if (null === self::$_filter) {
00124             require_once 'Zend/Filter/Alnum.php';
00125             self::$_filter = new Zend_Filter_Alnum();
00126         }
00127 
00128         self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
00129 
00130         if ($value != self::$_filter->filter($value)) {
00131             $this->_error(self::NOT_ALNUM);
00132             return false;
00133         }
00134 
00135         return true;
00136     }
00137 
00138 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2