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


PHP Zend_Validate_Between::setMessage方法代码示例

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


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

示例1: init

 public function init()
 {
     parent::init();
     if (is_null($this->getAttrib('size'))) {
         $this->setAttrib('size', 6);
     }
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $options = array();
     $min = $this->getAttrib('min');
     if (is_null($min)) {
         $min = 0;
     } else {
         $this->setAttrib('min', null);
         // remove from rendered attributes
     }
     $options['min'] = $min;
     $max = $this->getAttrib('max');
     if (is_null($max)) {
         $validator = new Zend_Validate_GreaterThan(array('min' => $min - 1));
         // inclusive not supported in ZF1
         $validator->setMessage('validation_error_number_tooSmall');
     } else {
         $this->setAttrib('max', null);
         // remove from rendered attributes
         $options['max'] = $max;
         $validator = new Zend_Validate_Between(array('min' => $min, 'max' => $max));
         $validator->setMessage('validation_error_number_notBetween');
     }
     $this->addValidator($validator);
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:32,代码来源:Number.php

示例2: testValidatorBreakChain

    public function testValidatorBreakChain()
    {
        $data = array(
            'field1' => '150',
            'field2' => '150'
        );

        Zend_Loader::loadClass('Zend_Validate_Between');

        $btw1 = new Zend_Validate_Between(1, 100);

        $btw2 = new Zend_Validate_Between(1, 125);
        $messageUserDefined = 'Something other than the default message';
        $btw2->setMessage($messageUserDefined, Zend_Validate_Between::NOT_BETWEEN);

        $validators = array(
            'field1' => array($btw1, $btw2),
            'field2' => array($btw1, $btw2, Zend_Filter_Input::BREAK_CHAIN => true)
        );
        $input = new Zend_Filter_Input(null, $validators, $data);

        $this->assertFalse($input->hasMissing(), 'Expected hasMissing() to return false');
        $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true');
        $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
        $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');

        $messages = $input->getMessages();
        $this->assertType('array', $messages);
        $this->assertEquals(array('field1', 'field2'), array_keys($messages));
        $this->assertEquals(
            $messageUserDefined,
            current($messages['field1']),
            'Expected message to break 2 validators, the message of the latter overwriting that of the former'
            );
        $this->assertEquals(
            "'150' is not between '1' and '100', inclusively",
            current($messages['field2']),
            'Expected rule for field2 to break the validation chain at the first validator'
            );
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:40,代码来源:InputTest.php

示例3: _getValidatorBetween

 /**
  *
  * @param type $min
  * @param type $max
  * @param type $messages_prefixed
  * @return \Zend_Validate_Between 
  */
 protected function _getValidatorBetween($min = 5, $max = 100, $messages_prefixed = "")
 {
     $between = new Zend_Validate_Between(array('min' => $min, 'max' => $max));
     $between->setMessage(sprintf($this->_translate('ERROR_BETWEEN'), $this->_translate($messages_prefixed), $min, $max), Zend_Validate_Between::NOT_BETWEEN);
     return $between;
 }
开发者ID:BGCX067,项目名称:facebook-store-svn-to-git,代码行数:13,代码来源:Form.php

示例4: validate

 /**
  * returns an validator for settings params or error array
  *
  * @return Zend_Filter_Input|array on success data on error message array
  * @param array $data current data for validation
  */
 public function validate($data)
 {
     // define filter
     $filterTrim = new Zend_Filter_StringTrim();
     $filter = array('deleteItems' => $filterTrim, 'imagesPosition' => $filterTrim, 'imagesHeight' => $filterTrim, 'language' => $filterTrim, 'refresh' => $filterTrim, 'lastrefresh' => $filterTrim, 'view' => $filterTrim, 'offset' => $filterTrim, 'itemsperpage' => $filterTrim, 'selected' => $filterTrim, 'dateFilter' => $filterTrim, 'dateStart' => $filterTrim, 'dateEnd' => $filterTrim, 'search' => $filterTrim, 'unread' => $filterTrim, 'starred' => $filterTrim, 'currentPriorityStart' => $filterTrim, 'currentPriorityEnd' => $filterTrim, 'saveOpenCategories' => $filterTrim, 'openCategories' => $filterTrim, 'firstUnread' => $filterTrim, 'newWindow' => $filterTrim, 'public' => $filterTrim, 'anonymizer' => $filterTrim, 'sort' => $filterTrim, 'openitems' => $filterTrim, 'iconcache' => $filterTrim);
     // define validators
     $validatorType = new Zend_Validate_InArray(array("both", "multimedia", "messages"));
     $validatorType->setMessage(Zend_Registry::get('language')->translate('Only both, multimedia, message allowed'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validatorNotEmpty = new Zend_Validate_NotEmpty();
     $validatorNotEmpty->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_NotEmpty::IS_EMPTY);
     $validatorNum = new Zend_Validate_Int(Zend_Registry::get('session')->language);
     $validatorNum->setLocale(Zend_Registry::get('session')->language);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate('Only digits allowed'), Zend_Validate_Int::NOT_INT);
     $validatorInArray = new Zend_Validate_InArray(array("top", "bottom"));
     $validatorInArray->setMessage(Zend_Registry::get('language')->translate('Only top or bottom allowed'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validatorLanguage = new Zend_Validate_InArray(Zend_Registry::get('language')->getList());
     $validatorLanguage->setMessage(Zend_Registry::get('language')->translate('Language is not available'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validatorDate = new Zend_Validate_Date();
     $validatorDate->setMessage(Zend_Registry::get('language')->translate('No valid date given'), Zend_Validate_Date::INVALID);
     $validatorDate->setMessage(Zend_Registry::get('language')->translate('No valid date given'), Zend_Validate_Date::FALSEFORMAT);
     $validatorBiggerThanZero = new Zend_Validate_GreaterThan(0);
     $validatorBiggerThanZero->setMessage(Zend_Registry::get('language')->translate('Value must be bigger than 0'), Zend_Validate_GreaterThan::NOT_GREATER);
     $validatorBetweenDays = new Zend_Validate_Between(0, 2000);
     $validatorBetweenDays->setMessage(Zend_Registry::get('language')->translate('Please choose a value between 0 and 2000 days'), Zend_Validate_Between::NOT_BETWEEN);
     $validatorBetweenItemsperpage = new Zend_Validate_Between(0, 200);
     $validatorBetweenItemsperpage->setMessage(Zend_Registry::get('language')->translate('Please choose a value between 0 and 200 items per page'), Zend_Validate_Between::NOT_BETWEEN);
     $validatorSort = new Zend_Validate_InArray(array("date", "dateasc", "priority", "priorityasc"));
     $validatorSort->setMessage(Zend_Registry::get('language')->translate('Only date or rating allowed'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validators = array('deleteItems' => array($validatorNum, $validatorBetweenDays, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'imagesPosition' => array($validatorInArray, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'language' => array($validatorLanguage, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'refresh' => array($validatorNum, $validatorBiggerThanZero, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'lastrefresh' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'view' => array($validatorType, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'offset' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'itemsperpage' => array($validatorNum, $validatorBetweenItemsperpage, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'selected' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'dateFilter' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'search' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'unread' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'starred' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'currentPriorityStart' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'currentPriorityEnd' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'saveOpenCategories' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'openCategories' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'firstUnread' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'newWindow' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'public' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'anonymizer' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'sort' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL, $validatorSort), 'openitems' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'iconcache' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL));
     // optional check date
     if (isset($data['dateFilter']) && $data['dateFilter'] == 1) {
         $validators['dateStart'] = $validatorDate;
         $validators['dateEnd'] = $validatorDate;
     } else {
         $validators['dateStart'] = array(Zend_Filter_Input::ALLOW_EMPTY => true);
         $validators['dateEnd'] = array(Zend_Filter_Input::ALLOW_EMPTY => true);
         $data['dateStart'] = '';
         $data['dateEnd'] = '';
     }
     // create validation main object
     $validator = new Zend_Filter_Input($filter, $validators, $data, array(Zend_Filter_Input::NOT_EMPTY_MESSAGE => Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Filter_Input::BREAK_CHAIN => false));
     // return filter input object
     return parent::validate($validator);
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:50,代码来源:settings.php

示例5: overrideBetweenValidator

 public static function overrideBetweenValidator($p_min, $p_max)
 {
     $validator = new Zend_Validate_Between($p_min, $p_max, true);
     $validator->setMessage(_("'%value%' is not between '%min%' and '%max%', inclusively"), Zend_Validate_Between::NOT_BETWEEN);
     return $validator;
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:6,代码来源:ValidationTypes.php


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