• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Validate_Alpha类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Zend_Validate_Alpha的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Alpha类的具体用法?PHP Zend_Validate_Alpha怎么用?PHP Zend_Validate_Alpha使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Zend_Validate_Alpha类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: isValid

 public function isValid($sValue)
 {
     $sValue = preg_replace("/_/", " ", $sValue);
     $oAlphaValidator = new Zend_Validate_Alpha(array("allowWhiteSpace" => true));
     if ($oAlphaValidator->isValid($sValue)) {
         return true;
     }
     return false;
 }
开发者ID:lstaszak,项目名称:zf_zk_aleph,代码行数:9,代码来源:SpecialAlpha.php


示例2: alpha_all_language

 function alpha_all_language($elem)
 {
     include_once LIBRARY . "Zend/Validate/Alpha.php";
     $validator = new Zend_Validate_Alpha(array('allowWhiteSpace' => true));
     if ($validator->isValid($elem['value'])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:glial,项目名称:glial,代码行数:10,代码来源:Validation.php


示例3: validateAttributeValue

 /**
  * Validate attributes
  * 
  * @param string $validation attribute validation class name
  * @param string $value attribute value
  * @return array returns success and errors as array keys
  */
 protected function validateAttributeValue($validation, $value)
 {
     $valid = array('success' => TRUE, 'errors' => '');
     switch ($validation) {
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DECIMAL:
             if (!$this->decimalValidation) {
                 $this->decimalValidation = new Zend_Validate_Float();
             }
             $valid['success'] = $this->decimalValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid digits.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_EMAIL:
             if (!$this->emailValidation) {
                 $this->emailValidation = new Zend_Validate_EmailAddress();
             }
             $valid['success'] = $this->emailValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid email address.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_INT:
             if (!$this->intValidation) {
                 $this->intValidation = new Zend_Validate_Int();
             }
             $valid['success'] = $this->intValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid integer.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_LETTERS:
             if (!$this->letterValidation) {
                 $this->letterValidation = new Zend_Validate_Alpha(true);
             }
             $valid['success'] = $this->letterValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid characters.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DATE:
             $valid['success'] = strtotime($value) > 0;
             $valid['errors'] = '"' . $value . '" is invalid date.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_URL:
             if (!$this->urlValidation) {
                 $this->urlValidation = new Uni_Validate_Url();
             }
             $valid['success'] = $this->urlValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid url.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_IMAGE:
             if (empty($this->validExtensions)) {
                 $this->validExtensions = array('jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff');
             }
             $extPos = strrpos($value, '.');
             if (!$extPos || !empty($this->validExtensions) && !in_array(substr($value, $extPos + 1), $this->validExtensions)) {
                 $valid['success'] = FALSE;
                 $valid['errors'] = 'Invalid image was given.';
             }
             break;
         default:
             break;
     }
     return $valid;
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:65,代码来源:Abstract.php


示例4: setTypes

 /** Set the types of entity to retrieve data upon
  * @access public
  * @param type $types
  * @throws Pas_Geo_Mapit_Exception
  */
 public function setTypes($types)
 {
     if (is_array($types)) {
         foreach ($types as $type) {
             if (strlen($type) != 3) {
                 throw new Pas_Geo_Mapit_Exception('The area must be a three letter string');
             }
             $validator = new Zend_Validate_Alpha();
             if (!$validator->isValid($type)) {
                 throw new Pas_Geo_Mapit_Exception('Invalid characters used', 500);
             }
             if (!in_array($type, array_flip($this->_allowedTypes))) {
                 throw new Pas_Geo_Mapit_Exception('The area type of ' . $type . ' must be in allowed list');
             }
         }
         $this->_types = implode(',', $types);
     } else {
         throw new Pas_Geo_Mapit_Exception('Areas must be an array');
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:25,代码来源:Areas.php


示例5: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return array|true
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = $this->getAttribute()->getStoreLabel();
     $validateRules = $this->getAttribute()->getValidationRules();
     $inputValidation = ArrayObjectSearch::getArrayElementByName($validateRules, 'input_validation');
     if (!is_null($inputValidation)) {
         switch ($inputValidation) {
             case 'alphanumeric':
                 $validator = new \Zend_Validate_Alnum(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic or non-numeric characters.', $label), \Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new \Zend_Validate_Digits();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Digits::INVALID);
                 $validator->setMessage(__('"%1" contains non-numeric characters.', $label), \Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new \Zend_Validate_Alpha(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic characters.', $label), \Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 __("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 __("Invalid type given. String expected")
                 __("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 __("'%value%' does not match the expected structure for a DNS hostname")
                 __("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 __("'%value%' does not appear to be a valid local network name")
                 __("'%value%' does not appear to be a valid URI hostname")
                 __("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 __("'%value%' appears to be a local network name but local network names are not allowed")
                 __("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 __("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new \Zend_Validate_EmailAddress();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(__('"%1" uses too many characters.', $label), \Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(__("'%value%' looks like an IP address, which is not an acceptable format."), \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), \Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), \Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match it against the hostname schema for TLD '%tld%'."), \Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but cannot extract TLD part."), \Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(__("'%value%' does not look like a valid local network name."), \Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(__("'%value%' looks like a local network name, which is not an acceptable format."), \Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded."), \Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 $validator = new \Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 break;
             case 'date':
                 $validator = new \Zend_Validate_Date(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Date::INVALID);
                 $validator->setMessage(__('"%1" is not a valid date.', $label), \Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(__('"%1" does not fit the entered date format.', $label), \Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:AbstractData.php


示例6: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return string
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = Mage::helper('customer')->__($this->getAttribute()->getStoreLabel());
     $validateRules = $this->getAttribute()->getValidateRules();
     if (!empty($validateRules['input_validation'])) {
         switch ($validateRules['input_validation']) {
             case 'alphanumeric':
                 $validator = new Zend_Validate_Alnum(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic and digit characters.', $label), Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new Zend_Validate_Digits();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Digits::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" contains not only digit characters.', $label), Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new Zend_Validate_Alpha(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic characters.', $label), Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 $this->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 $this->__("Invalid type given. String expected")
                 $this->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 $this->__("'%value%' does not match the expected structure for a DNS hostname")
                 $this->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 $this->__("'%value%' does not appear to be a valid local network name")
                 $this->__("'%value%' does not appear to be a valid URI hostname")
                 $this->__("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 $this->__("'%value%' appears to be a local network name but local network names are not allowed")
                 $this->__("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 $this->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new Zend_Validate_EmailAddress();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" exceeds the allowed length.', $label), Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be an IP address, but IP addresses are not allowed"), Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list"), Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position"), Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'"), Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot extract TLD part"), Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' does not appear to be a valid local network name"), Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a local network name but local network names are not allowed"), Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded"), Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 $validator = new Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 break;
             case 'date':
                 $validator = new Zend_Validate_Date(Varien_Date::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Date::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid date.', $label), Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" does not fit the entered date format.', $label), Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
         }
     }
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:101,代码来源:Abstract.php


示例7: require_once

<?
require_once('Zend/Validate/Alpha.php');
require_once($cfg['path'] . '/models/calls.php');
require_once($cfg['path'] . '/helpers/workTimeInterval.php');


$writer = new Zend_Log_Writer_Stream($log_calls);
$logger    = new Zend_Log($writer);

$tpl['addcall']['errors'] = array();
$tpl['addcall']['callfio'] = isset($_REQUEST['callfio'])?$_REQUEST['callfio']:"";
$tpl['addcall']['callphone'] = isset($_REQUEST['callphone'])?$_REQUEST['callphone']:"";

$tpl['addcall']['send_status'] = false;

$validator_text = new Zend_Validate_Alpha(array('allowWhiteSpace' => true));


if($_SERVER['REQUEST_METHOD']=='POST'){
    if(!$tpl['addcall']['callfio']){
        $tpl['addcall']['errors'][] = "Вы не указали имя";
    }
    if(!$tpl['addcall']['callphone']){
        $tpl['addcall']['errors'][] = "Введите номер телефона";
    }
    if(!$validator_text->isValid($tpl['addcall']['callfio'])){
    	$tpl['addcall']['errors'][] = "Поле имя должно содержать только буквы!";
    }
    if(!$tpl['addcall']['errors']){
        $calls = new model_addcall($db_class);
        if($calls->isCallExist($tpl['addcall']['callphone'])){
开发者ID:nellka,项目名称:numiz-new,代码行数:31,代码来源:addcall.ctl.php


示例8: testElementsTranslatorDoesntOverrideValidatorsDirectlyAttachedTranslator

 /**
  * @group ZF-9275
  */
 public function testElementsTranslatorDoesntOverrideValidatorsDirectlyAttachedTranslator()
 {
     $elementTranslations = array('alphaInvalid' => 'Element message');
     $elementTranslate = new Zend_Translate('array', $elementTranslations);
     $validatorTranslations = array('alphaInvalid' => 'Direct validator message');
     $validatorTranslate = new Zend_Translate('array', $validatorTranslations);
     $validator = new Zend_Validate_Alpha();
     $validator->setTranslator($validatorTranslate);
     $this->element->addValidator($validator);
     $this->assertFalse($this->element->isValid(123));
     $messages = $this->element->getMessages();
     $this->assertEquals('Direct validator message', $messages['alphaInvalid']);
 }
开发者ID:netvlies,项目名称:zf,代码行数:16,代码来源:ElementTest.php


示例9: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return string
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = $this->getAttribute()->getStoreLabel();
     $validateRules = $this->getAttribute()->getValidateRules();
     if (!empty($validateRules['input_validation'])) {
         switch ($validateRules['input_validation']) {
             case 'alphanumeric':
                 $validator = new Zend_Validate_Alnum(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic and digit characters.', $label), Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new Zend_Validate_Digits();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Digits::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" contains not only digit characters.', $label), Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new Zend_Validate_Alpha(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic characters.', $label), Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 $validator = new Zend_Validate_EmailAddress();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" exceeds the allowed length.', $label), Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 $validator = new Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 break;
             case 'date':
                 $format = Mage::app()->getLocale()->getDateFormat(Varien_Date::DATE_INTERNAL_FORMAT);
                 $validator = new Zend_Validate_Date($format);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Date::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid date.', $label), Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" does not fit the entered date format.', $label), Zend_Validate_Date::FALSEFORMAT);
                 break;
         }
     }
     return true;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:79,代码来源:Abstract.php


示例10: setFilter

 /** Set the filter up for method calls
  * @access public
  * @param type $type
  * @return type
  * @throws Pas_Geo_Mapit_Exception
  */
 public function setFilter($type)
 {
     if (strlen($type) != 3) {
         throw new Pas_Geo_Mapit_Exception('The area must be a three letter string');
     }
     $validator = new Zend_Validate_Alpha();
     if (!$validator->isValid($type)) {
         throw new Pas_Geo_Mapit_Exception('Invalid characters used', 500);
     }
     if (!in_array($type, array_flip($this->_allowedTypes))) {
         throw new Pas_Geo_Mapit_Exception('The area type of ' . $type . ' must be in allowed list');
     }
     return $this->_filter = '?type=' . $type;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:20,代码来源:Area.php


示例11: isAlpha

 /**
  * Returns TRUE if every character is alphabetic, FALSE
  * otherwise.
  *
  * @deprecated since 0.8.0
  * @param      mixed $value
  * @return     boolean
  */
 public static function isAlpha($value)
 {
     require_once 'Zend/Validate/Alpha.php';
     $validator = new Zend_Validate_Alpha();
     return $validator->isValid($value);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:Filter.php


示例12: isValid

 /**
  * Validate fullName
  *
  * @static
  * @param $fullName
  * @return bool
  */
 public static function isValid($fullName)
 {
     $validator = new Zend_Validate_Alpha(array('allowWhiteSpace' => true));
     return $validator->isValid($fullName);
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:12,代码来源:FullName.php


示例13: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array('abc123' => false, 'abc 123' => false, 'abcxyz' => true, 'AZ@#4.3' => false, 'aBc123' => false, 'aBcDeF' => true);
     foreach ($valuesExpected as $input => $result) {
         $this->assertEquals($result, $this->_validator->isValid($input));
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:AlphaTest.php


示例14: testAllowWhiteSpace

 /**
  * Ensures that the allowWhiteSpace option works as expected
  *
  * @return void
  */
 public function testAllowWhiteSpace()
 {
     $this->_validator->allowWhiteSpace = true;
     $valuesExpected = array('abc123' => false, 'abc 123' => false, 'abcxyz' => true, 'AZ@#4.3' => false, 'aBc123' => false, 'aBcDeF' => true, '' => false, ' ' => true, "\n" => true, " \t " => true, "a\tb c" => true);
     foreach ($valuesExpected as $input => $result) {
         $this->assertEquals($result, $this->_validator->isValid($input), "Expected '{$input}' to be considered " . ($result ? '' : 'in') . "valid");
     }
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:13,代码来源:AlphaTest.php


示例15: isValid

 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     if ('' === $valueString) {
         $this->_error(self::STRING_EMPTY);
         return false;
     }
     if (null === self::$_filter) {
         require_once 'Zend/Filter/Alpha.php';
         self::$_filter = new Zend_Filter_Alpha();
     }
     self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
     if ($valueString !== self::$_filter->filter($valueString)) {
         $this->_error(self::NOT_ALPHA);
         return false;
     }
     return true;
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:19,代码来源:Alpha.php


示例16: isValid

 /**
  * Defined by 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 Zend_Filter_Alpha
          */
         require_once 'Zend/Filter/Alpha.php';
         self::$_filter = new Zend_Filter_Alpha();
     }
     self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
     if ($value !== self::$_filter->filter($value)) {
         $this->_error(self::NOT_ALPHA);
         return false;
     }
     return true;
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:33,代码来源:Alpha.php


示例17: testNonStringValidation

 /**
  * @ZF-4352
  */
 public function testNonStringValidation()
 {
     $this->assertFalse($this->_validator->isValid(array(1 => 1)));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:7,代码来源:AlphaTest.php


示例18: validateFilterSort

 /**
  * @param  string  $sort
  * @return boolean
  */
 private function validateFilterSort($sort)
 {
     $alphaValidator = new AlphaValidator();
     $alphaValidator->setMessage("Filter sort ist kein String", AlphaValidator::INVALID);
     $alphaValidator->setMessage("Filter sort '%value%' enthält nicht alphabetische Character", AlphaValidator::NOT_ALPHA);
     if (!$alphaValidator->isValid($sort)) {
         $messages = array_values($alphaValidator->getMessages());
         $this->addError(new Error('sort', $sort, $messages));
         return false;
     }
     return true;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:16,代码来源:Media.php


示例19: __construct

 public function __construct($allowWhiteSpace = false)
 {
     parent::__construct($allowWhiteSpace);
     $this->_messageTemplates[self::NOT_ALPHA] = trlKwfStatic("'%value%' has not only alphabetic characters");
     $this->_messageTemplates[self::STRING_EMPTY] = trlKwfStatic("'%value%' is an empty string");
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:6,代码来源:Alpha.php


示例20: testGetMessages

 /**
  * Ensures that getMessages() returns expected default value
  *
  * @return void
  */
 public function testGetMessages()
 {
     $this->assertEquals(array(), $this->_validator->getMessages());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:AlphaTest.php



注:本文中的Zend_Validate_Alpha类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Validate_Barcode类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Validate_Alnum类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap