Example #1
0
 /**
  * Defined by IfwPsn_Vendor_Zend_Validate_Interface
  *
  * Returns true if and only if $value contains only alphabetic characters
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     if (!is_string($value)) {
         $this->_error(self::INVALID);
         return false;
     }
     $this->_setValue($value);
     if ('' === $value) {
         $this->_error(self::STRING_EMPTY);
         return false;
     }
     if (null === self::$_filter) {
         /**
          * @see IfwPsn_Vendor_Zend_Filter_Alpha
          */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Alpha.php';
         self::$_filter = new IfwPsn_Vendor_Zend_Filter_Alpha();
     }
     self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
     if ($value !== self::$_filter->filter($value)) {
         $this->_error(self::NOT_ALPHA);
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Sets default option values for this instance
  *
  * @param  boolean $allowWhiteSpace
  * @return void
  */
 public function __construct($allowWhiteSpace = false)
 {
     if ($allowWhiteSpace instanceof IfwPsn_Vendor_Zend_Config) {
         $allowWhiteSpace = $allowWhiteSpace->toArray();
     } else {
         if (is_array($allowWhiteSpace)) {
             if (array_key_exists('allowwhitespace', $allowWhiteSpace)) {
                 $allowWhiteSpace = $allowWhiteSpace['allowwhitespace'];
             } else {
                 $allowWhiteSpace = false;
             }
         }
     }
     $this->allowWhiteSpace = (bool) $allowWhiteSpace;
     if (null === self::$_unicodeEnabled) {
         self::$_unicodeEnabled = @preg_match('/\\pL/u', 'a') ? true : false;
     }
     if (null === self::$_meansEnglishAlphabet) {
         $this->_locale = new IfwPsn_Vendor_Zend_Locale('auto');
         self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), array('ja', 'ko', 'zh'));
     }
 }