当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Validate_Regex::isValid方法代码示例

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


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

示例1: getPreview

 public static function getPreview($page, $crop = false)
 {
     $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config');
     $path = (bool) $crop ? $websiteHelper->getPreviewCrop() : $websiteHelper->getPreview();
     if (is_numeric($page)) {
         $page = Application_Model_Mappers_PageMapper::getInstance()->find(intval($page));
     }
     if ($page instanceof Application_Model_Models_Page) {
         $validator = new Zend_Validate_Regex('~^https?://.*~');
         $preview = $page->getPreviewImage();
         if (!is_null($preview)) {
             if ($validator->isValid($preview)) {
                 return $preview;
             } else {
                 $websiteUrl = $configHelper->getConfig('mediaServers') ? Tools_Content_Tools::applyMediaServers($websiteHelper->getUrl()) : $websiteHelper->getUrl();
                 $previewPath = $websiteHelper->getPath() . $path . $preview;
                 if (is_file($previewPath)) {
                     return $websiteUrl . $path . $preview;
                 }
             }
         }
     }
     return $websiteHelper->getUrl() . self::PLACEHOLDER_NOIMAGE;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:25,代码来源:Tools.php

示例2: _beforeSave

 /**
  * Processing object before save data
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _beforeSave()
 {
     //validate attribute_code
     $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
     if (!$validatorAttrCode->isValid($this->getAttributeCode())) {
         Mage::throwException(Mage::helper('mep')->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'));
     }
     return parent::_beforeSave();
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:14,代码来源:Mapping.php

示例3: isValid

 /**
  * Validate element value
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($value, $context = null)
 {
     $v1 = new Zend_Validate_Regex('/^\\d{4}\\-\\d{2}\\-\\d{2}$/');
     $v2 = new Zend_Validate_Date(array('format' => 'Y-m-d'));
     if (!$v1->isValid($value) || !$v2->isValid($value)) {
         $this->_messages = array(self::INVALID_DATE_FORMAT => $this->_templateMessages[self::INVALID_DATE_FORMAT]);
         return false;
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:17,代码来源:DateInterval.php

示例4: isValid

 public function isValid($value)
 {
     $validator = new Zend_Validate_Regex(array('pattern' => '~^(http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\'/\\\\+&%\\$#\\=\\~])*[^\\.\\,\\)\\(\\s]$~'));
     $this->_setValue($value);
     if (!$validator->isValid($value)) {
         $this->_error(self::URL);
         return false;
     }
     return true;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:10,代码来源:UrlRegex.php

示例5: validate

 public function validate($object)
 {
     $validator = new Zend_Validate_Regex(array('pattern' => '/(^\\d+(\\.{0,1}\\d{0,})(;\\d+(\\.{0,1}\\d{0,}))+$)|^$/'));
     $attrCode = $this->getAttribute()->getAttributeCode();
     $value = $object->getData($attrCode);
     $price = $object->getData('price');
     if (!($price > 0)) {
         if (!$validator->isValid($value)) {
             Mage::throwException('Not correct value. Example: 100;200.33;300.56');
         }
     }
 }
开发者ID:bevello,项目名称:bevello,代码行数:12,代码来源:Additionalprice.php

示例6: isValid

 public function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     $validator = new \Zend_Validate_StringLength();
     $validator->setMax(128);
     if (!$validator->isValid($value)) {
         $this->_messages = $validator->getMessages();
         return false;
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:EmailAddress.php

示例7: isValid

 /**
  * Modified function validates input pattern.
  * @param string $value
  * @return boolean - True only if date input is valid for Opus requirements
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     // Check first if input matches expected pattern
     $datePattern = $this->getInputPattern();
     $validator = new Zend_Validate_Regex($datePattern);
     if (!$validator->isValid($value)) {
         $this->_error(Zend_Validate_Date::FALSEFORMAT);
         return false;
     }
     // Perform check in parent class
     return parent::isValid($value);
 }
开发者ID:alexukua,项目名称:opus4,代码行数:18,代码来源:Date.php

示例8: login

 public function login($username, $password)
 {
     // Remove backslashes
     $username = str_replace("\\", "", $username);
     // filter data from the user
     $f = new Zend_Filter_StripTags();
     $this->user = $f->filter($username);
     $this->pwd = $f->filter($password);
     // Validate credentials
     if (empty($username)) {
         throw new Exception('Invalid username');
     }
     if (empty($password)) {
         throw new Exception('Invalid password');
     }
     // Username can be alphanum with dash, underscore, @, periods and apostrophe
     $usernameValidator = new Zend_Validate_Regex('/^([A-Za-z0-9-_@\\.\']+)$/');
     if (!$usernameValidator->isValid($username)) {
         throw new Exception('Please enter a valid username');
     }
     // setup Zend_Auth adapter for a database table
     $this->db->setFetchMode(Zend_Db::FETCH_ASSOC);
     $authAdapter = new Zend_Auth_Adapter_DbTable($this->db);
     $authAdapter->setTableName('ol_admins');
     $authAdapter->setIdentityColumn('user');
     $authAdapter->setCredentialColumn('password');
     // Set the input credential values to authenticate against
     $authAdapter->setIdentity($username);
     $authAdapter->setCredential(md5($password));
     $authAdapter->getDbSelect()->where('active = ?', 1);
     // MUST be an active account
     // do the authentication
     $result = $this->auth->authenticate($authAdapter);
     $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
     if (!$result->isValid()) {
         throw new Exception('Login failed.');
     }
     //var_dump($authAdapter->getResultRowObject()); exit();
     // Update last login date
     $users = new OneLogin_Acl_Users();
     $users->updateLastLoginDate($username);
     // Define object and set auth information
     $objUser = new stdClass();
     $objUser->user_id = $authAdapter->getResultRowObject()->id;
     $objUser->api_user_username = $username;
     $objUser->api_user_password = $password;
     $objUser->active = $authAdapter->getResultRowObject()->active;
     $this->auth->getStorage()->write($objUser);
 }
开发者ID:juliomolinero,项目名称:onelogin-api-php,代码行数:49,代码来源:Login.php

示例9: validate

 private function validate()
 {
     $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
     if (!$validatorAttrCode->isValid($this->code)) {
         return false;
     }
     if (empty($this->primaryLabel)) {
         return false;
     }
     /** @var $validatorInputType Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator */
     $validatorInputType = Mage::getModel('eav/adminhtml_system_config_source_inputtype_validator');
     if (!$validatorInputType->isValid($this->inputType)) {
         return false;
     }
     return true;
 }
开发者ID:Vitafy,项目名称:M2E,代码行数:16,代码来源:Builder.php

示例10: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     /**
      * The elements of each array are, in order:
      *      - pattern
      *      - expected validation result
      *      - array of test input values
      */
     $valuesExpected = array(array('/[a-z]/', true, array('abc123', 'foo', 'a', 'z')), array('/[a-z]/', false, array('123', 'A')));
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_Regex($element[0]);
         foreach ($element[2] as $input) {
             $this->assertEquals($element[1], $validator->isValid($input));
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:21,代码来源:RegexTest.php

示例11: isValid

 /**
  * Validate element value
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($value, $context = array())
 {
     // Optional?
     if (empty($value) && $this->_optional) {
         return true;
     }
     $lengthValidator = new Zend_Validate_StringLength(array('min' => 5, 'max' => 62));
     if (!$lengthValidator->isValid($value)) {
         $this->_messages = $lengthValidator->getMessages();
         return false;
     }
     $regexValidator = new Zend_Validate_Regex(array('pattern' => '/^(?!(RAC|LAC|SGSN|RNC|\\.))(\\.?[0-9a-z]+(\\-[0-9a-z]+)*)+(?<!(\\.GPRS$))$/i'));
     if (!$regexValidator->isValid($value)) {
         $this->_messages = $regexValidator->getMessages();
         return false;
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:25,代码来源:Apn.php

示例12: validate

 private function validate()
 {
     $validatorAttrCode = new \Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
     if (!$validatorAttrCode->isValid($this->code)) {
         return false;
     }
     if (strlen($this->code) > self::CODE_MAX_LENGTH) {
         return false;
     }
     if (empty($this->primaryLabel)) {
         return false;
     }
     $validatorInputType = $this->inputTypeValidatorFactory->create();
     if (!$validatorInputType->isValid($this->inputType)) {
         return false;
     }
     return true;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:Builder.php

示例13: execute

 /**
  * @return \Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function execute()
 {
     $data = $this->getRequest()->getPostValue();
     $resultRedirect = $this->resultRedirectFactory->create();
     if ($data) {
         $setId = $this->getRequest()->getParam('set');
         $attributeSet = null;
         if (!empty($data['new_attribute_set_name'])) {
             $name = $this->filterManager->stripTags($data['new_attribute_set_name']);
             $name = trim($name);
             try {
                 /** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
                 $attributeSet = $this->buildFactory->create()->setEntityTypeId($this->_entityTypeId)->setSkeletonId($setId)->setName($name)->getAttributeSet();
             } catch (AlreadyExistsException $alreadyExists) {
                 $this->messageManager->addError(__('An attribute set named \'%1\' already exists.', $name));
                 $this->messageManager->setAttributeData($data);
                 return $resultRedirect->setPath('catalog/*/edit', ['_current' => true]);
             } catch (\Magento\Framework\Exception\LocalizedException $e) {
                 $this->messageManager->addError($e->getMessage());
             } catch (\Exception $e) {
                 $this->messageManager->addException($e, __('Something went wrong while saving the attribute.'));
             }
         }
         $redirectBack = $this->getRequest()->getParam('back', false);
         /* @var $model \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
         $model = $this->attributeFactory->create();
         $attributeId = $this->getRequest()->getParam('attribute_id');
         $attributeCode = $this->getRequest()->getParam('attribute_code');
         $frontendLabel = $this->getRequest()->getParam('frontend_label');
         $attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]);
         if (strlen($this->getRequest()->getParam('attribute_code')) > 0) {
             $validatorAttrCode = new \Zend_Validate_Regex(['pattern' => '/^[a-z][a-z_0-9]{0,30}$/']);
             if (!$validatorAttrCode->isValid($attributeCode)) {
                 $this->messageManager->addError(__('Attribute code "%1" is invalid. Please use only letters (a-z), ' . 'numbers (0-9) or underscore(_) in this field, first character should be a letter.', $attributeCode));
                 return $resultRedirect->setPath('catalog/*/edit', ['attribute_id' => $attributeId, '_current' => true]);
             }
         }
         $data['attribute_code'] = $attributeCode;
         //validate frontend_input
         if (isset($data['frontend_input'])) {
             /** @var $inputType \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator */
             $inputType = $this->validatorFactory->create();
             if (!$inputType->isValid($data['frontend_input'])) {
                 foreach ($inputType->getMessages() as $message) {
                     $this->messageManager->addError($message);
                 }
                 return $resultRedirect->setPath('catalog/*/edit', ['attribute_id' => $attributeId, '_current' => true]);
             }
         }
         if ($attributeId) {
             $model->load($attributeId);
             if (!$model->getId()) {
                 $this->messageManager->addError(__('This attribute no longer exists.'));
                 return $resultRedirect->setPath('catalog/*/');
             }
             // entity type check
             if ($model->getEntityTypeId() != $this->_entityTypeId) {
                 $this->messageManager->addError(__('We can\'t update the attribute.'));
                 $this->_session->setAttributeData($data);
                 return $resultRedirect->setPath('catalog/*/');
             }
             $data['attribute_code'] = $model->getAttributeCode();
             $data['is_user_defined'] = $model->getIsUserDefined();
             $data['frontend_input'] = $model->getFrontendInput();
         } else {
             /**
              * @todo add to helper and specify all relations for properties
              */
             $data['source_model'] = $this->productHelper->getAttributeSourceModelByInputType($data['frontend_input']);
             $data['backend_model'] = $this->productHelper->getAttributeBackendModelByInputType($data['frontend_input']);
         }
         $data += ['is_filterable' => 0, 'is_filterable_in_search' => 0, 'apply_to' => []];
         if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
             $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
         }
         $defaultValueField = $model->getDefaultValueByInput($data['frontend_input']);
         if ($defaultValueField) {
             $data['default_value'] = $this->getRequest()->getParam($defaultValueField);
         }
         if (!$model->getIsUserDefined() && $model->getId()) {
             // Unset attribute field for system attributes
             unset($data['apply_to']);
         }
         $model->addData($data);
         if (!$attributeId) {
             $model->setEntityTypeId($this->_entityTypeId);
             $model->setIsUserDefined(1);
         }
         $groupCode = $this->getRequest()->getParam('group');
         if ($setId && $groupCode) {
             // For creating product attribute on product page we need specify attribute set and group
             $attributeSetId = $attributeSet ? $attributeSet->getId() : $setId;
             $groupCollection = $attributeSet ? $attributeSet->getGroups() : $this->groupCollectionFactory->create()->setAttributeSetFilter($attributeSetId)->load();
             foreach ($groupCollection as $group) {
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:101,代码来源:Save.php

示例14: testNonStringValidation

 /**
  * @ZF-4352
  */
 public function testNonStringValidation()
 {
     $validator = new Zend_Validate_Regex('/');
     $this->assertFalse($validator->isValid(array(1 => 1)));
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:8,代码来源:RegexTest.php

示例15: isValid

 function isValid($value)
 {
     $nameValidator = new Zend_Validate_Regex("/^[0-9a-zA-ZÀ-ú]+[0-9A-Za-zÀ-ú\\'\\[\\]\\(\\)\\-\\.\\,\\:\\;\\!\\?\\/ ]{1,120}\$/");
     return $nameValidator->isValid($value);
 }
开发者ID:racporto,项目名称:c3op,代码行数:5,代码来源:InstitutionValidName.php


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