當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Validate_StringLength::getMessages方法代碼示例

本文整理匯總了PHP中Zend_Validate_StringLength::getMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Validate_StringLength::getMessages方法的具體用法?PHP Zend_Validate_StringLength::getMessages怎麽用?PHP Zend_Validate_StringLength::getMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Validate_StringLength的用法示例。


在下文中一共展示了Zend_Validate_StringLength::getMessages方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetErrors

 /**
  * Ensures that the getError() function returns an array of
  * message key values corresponding to the messages.
  *
  * @return void
  */
 public function testGetErrors()
 {
     $this->assertFalse($this->_validator->isValid('abcdefghij'));
     $messages = $this->_validator->getMessages();
     $this->assertEquals("'abcdefghij' is greater than 8 characters long", $messages[0]);
     $errors = $this->_validator->getErrors();
     $this->assertEquals(Zend_Validate_StringLength::TOO_LONG, $errors[0]);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:14,代碼來源:MessageTest.php

示例2: _validateDescription

 /**
  * Validates job description
  *
  * @return boolean
  */
 protected function _validateDescription()
 {
     $validator = new Zend_Validate_StringLength(2);
     if ($validator->isValid($this->category->getDescription())) {
         return true;
     }
     $msg = Sanmax_MessageStack::getInstance('SxCms_Job_Category');
     $msg->addMessage('description', $validator->getMessages());
     return false;
 }
開發者ID:sonvq,項目名稱:2015_freelance6,代碼行數:15,代碼來源:BaseValidator.php

示例3: _validateIdentifier

 protected function _validateIdentifier()
 {
     $validator = new Zend_Validate_StringLength(2, 255);
     if ($validator->isValid($this->_group->getIdentifier())) {
         return true;
     }
     $msg = Sanmax_MessageStack::getInstance('SxCms_Group');
     $msg->addMessage('identifier', $validator->getMessages());
     return false;
 }
開發者ID:sonvq,項目名稱:2015_freelance6,代碼行數:10,代碼來源:BaseValidator.php

示例4: validateType

 public function validateType($type)
 {
     $validator = new Zend_Validate_StringLength(2, 255);
     if ($validator->isValid($type)) {
         return true;
     }
     $msg = Sanmax_MessageStack::getInstance($this->_messagestack_name());
     $msg->addMessage('pf_type', $validator->getMessages(), 'common');
     return false;
 }
開發者ID:sonvq,項目名稱:2015_freelance6,代碼行數:10,代碼來源:Validator.php

示例5: validatePrepare

 /**
  * @param mixed|string $prepare
  * @param string       $requestKey
  *
  * @return bool
  */
 protected function validatePrepare($prepare, $requestKey)
 {
     $stringLengthValidator = new StringLengthValidator(array('min' => 1, 'max' => 255));
     if (!$stringLengthValidator->isValid(trim($prepare))) {
         $messages = array_values($stringLengthValidator->getMessages());
         $this->addError(new Error($requestKey, $prepare, $messages));
         return false;
     }
     return true;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:16,代碼來源:Creator.php

示例6: validatePassword

 public function validatePassword($text, $name = 'example', $tab = 'common')
 {
     $validator = new Zend_Validate_StringLength(6, 32);
     if ($validator->isValid($text)) {
         return true;
     }
     $msg = Sanmax_MessageStack::getInstance($this->_namespace);
     $msg->addMessage($name, $validator->getMessages(), $tab);
     return false;
 }
開發者ID:sonvq,項目名稱:2015_freelance6,代碼行數:10,代碼來源:Validator.php

示例7: validateGroup

 public function validateGroup()
 {
     $validator = new Zend_Validate_StringLength(2, 255);
     $validator->setMessage($this->_tmx->_('error.verplicht.min'), Zend_Validate_StringLength::TOO_SHORT);
     $validator->setMessage($this->_tmx->_('error.verplicht.max'), Zend_Validate_StringLength::TOO_LONG);
     if ($validator->isValid($this->_group)) {
         return true;
     }
     $msg = Sanmax_MessageStack::getInstance('SxModule_Securedocs_Group');
     $msg->addMessage('group', $validator->getMessages(), 'settings');
     return false;
 }
開發者ID:sonvq,項目名稱:2015_freelance6,代碼行數:12,代碼來源:Group.php

示例8: validateComment

 /**
  * @param  string $comment
  * @return boolean
  */
 private function validateComment($comment)
 {
     $stringLengthValidator = new StringLengthValidator(array('min' => 0, 'max' => self::MAX_ZIP_COMMENT_LENGTH));
     $stringLengthValidator->setMessage('Build Kommentar zu kurz', StringLengthValidator::TOO_SHORT);
     $stringLengthValidator->setMessage('Build Kommentar zu lang', StringLengthValidator::TOO_LONG);
     if (!$stringLengthValidator->isValid(trim($comment))) {
         $messages = array_values($stringLengthValidator->getMessages());
         $this->addError(new Error('comment', $comment, $messages));
         return false;
     }
     return true;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:16,代碼來源:Builder.php

示例9: validateName

 /**
  * @param  string $name
  * @return boolean
  */
 private function validateName($name)
 {
     $stringLengthValidator = new StringLengthValidator(array('min' => 2, 'max' => 255));
     $stringLengthValidator->setMessage('Album name zu kurz', StringLengthValidator::TOO_SHORT);
     $stringLengthValidator->setMessage('Album name zu lang', StringLengthValidator::TOO_LONG);
     if (!$stringLengthValidator->isValid(trim($name))) {
         $messages = array_values($stringLengthValidator->getMessages());
         $this->addError(new Error('name', $name, $messages));
         return false;
     }
     return true;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:16,代碼來源:Album.php

示例10: 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

示例11: testGetMessageVariables

 /**
  * Ensures that getMessageVariables() returns an array of
  * strings and that these strings that can be used as variables
  * in a message.
  */
 public function testGetMessageVariables()
 {
     $vars = $this->_validator->getMessageVariables();
     $this->assertType('array', $vars);
     $this->assertEquals(array('min', 'max'), $vars);
     $message = 'variables: %notvar% ';
     foreach ($vars as $var) {
         $message .= "%{$var}% ";
     }
     $this->_validator->setMessage($message, Zend_Validate_StringLength::TOO_SHORT);
     $this->assertFalse($this->_validator->isValid('abc'));
     $messages = $this->_validator->getMessages();
     $this->assertEquals('variables: %notvar% 4 8 ', current($messages));
 }
開發者ID:omusico,項目名稱:logica,代碼行數:19,代碼來源:MessageTest.php

示例12: testGetMessageVariables

 /**
  * Ensures that getMessageVariables() returns an array of
  * strings and that these strings that can be used as variables
  * in a message.
  */
 public function testGetMessageVariables()
 {
     $vars = $this->_validator->getMessageVariables();
     $this->assertType('array', $vars);
     $this->assertEquals(array('min', 'max'), $vars);
     $message = 'variables: %notvar% ';
     foreach ($vars as $var) {
         $message .= "%{$var}% ";
     }
     $this->_validator->setMessage($message);
     $this->assertFalse($this->_validator->isValid('abc'));
     $messages = $this->_validator->getMessages();
     $this->assertEquals('variables: %notvar% 4 8 ', $messages[0]);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:19,代碼來源:MessageTest.php

示例13: validateName

 /**
  * @param  string  $name
  * @return boolean
  */
 private function validateName($name)
 {
     $stringLengthValidator = new StringLengthValidator(array('min' => 1, 'max' => 255));
     $tooShortMessage = sprintf("Name '%s' zu kurz", ucfirst($name));
     $stringLengthValidator->setMessage($tooShortMessage, StringLengthValidator::TOO_SHORT);
     $tooLongMessage = sprintf("Name '%s' zu lang", ucfirst($name));
     $stringLengthValidator->setMessage($tooLongMessage, StringLengthValidator::TOO_LONG);
     if (!$stringLengthValidator->isValid(trim($name))) {
         $messages = array_values($stringLengthValidator->getMessages());
         $this->addError(new Error('name', $name, $messages));
         return false;
     }
     return true;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:18,代碼來源:Cdn.php

示例14: setObservacao

 /**
  * Seta o valor da coluna observacao
  *
  * @param string $value
  * @return Wf_Model_WfTransacao_Crud_Mapper
  */
 public function setObservacao($value, $options = array('required' => true))
 {
     $this->_data['observacao'] = new ZendT_Type_String($value);
     if ($options['db']) {
         $this->_data['observacao']->setValueFromDb($value);
     }
     if (!$options['db']) {
         $valid = new Zend_Validate_StringLength(array('max' => 300));
         $valueValid = $this->_data['observacao']->getValueToDb();
         if ($valueValid && !$valid->isValid($valueValid)) {
             throw new ZendT_Exception_Business(implode("\n", $valid->getMessages()));
         }
     }
     return $this;
 }
開發者ID:rtsantos,項目名稱:mais,代碼行數:21,代碼來源:Mapper.php

示例15: validateStr

 public function validateStr($str, $type, $len)
 {
     //Check each post variable for blanks or spaces
     $str_validator = new Zend_Validate_StringLength($len);
     $str_validator->setMessage($type . ', \'%value%\', is too short. It must be at least %min% ' . 'characters.', Zend_Validate_StringLength::TOO_SHORT);
     if ($str == $type || $str == "" || $str == " ") {
         $error = "Please enter " . strtolower($type) . ".";
         array_push($this->messages, $error);
     }
     if (!$str_validator->isValid($str)) {
         foreach ($str_validator->getMessages() as $error) {
             array_push($this->messages, $error);
         }
     }
     return $this->messages;
 }
開發者ID:kellancraddock,項目名稱:portfolio,代碼行數:16,代碼來源:Message.php


注:本文中的Zend_Validate_StringLength::getMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。