/** * Defined by IfwPsn_Vendor_Zend_Validate_Interface * * Returns true if and only if $value contains only alphabetic and digit characters * * @param string $value * @return boolean */ public function isValid($value) { if (!is_string($value) && !is_int($value) && !is_float($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_Alnum */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Alnum.php'; self::$_filter = new IfwPsn_Vendor_Zend_Filter_Alnum(); } self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; if ($value != self::$_filter->filter($value)) { $this->_error(self::NOT_ALNUM); return false; } return true; }
/** * 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')); } }