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


PHP Zend_Validate_StringLength::setMessage方法代碼示例

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


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

示例1: _createStringLengthValidator

 protected function _createStringLengthValidator($minValue, $maxValue, $minMessage, $maxMessage)
 {
     $stringLengthValidator = new Zend_Validate_StringLength(array('min' => $minValue, 'max' => $maxValue));
     $stringLengthValidator->setMessage($minMessage, Zend_Validate_StringLength::TOO_SHORT);
     $stringLengthValidator->setMessage($maxMessage, Zend_Validate_StringLength::TOO_LONG);
     return $stringLengthValidator;
 }
開發者ID:rizkioa,項目名稱:etak6,代碼行數:7,代碼來源:Form.php

示例2: overrideStringLengthValidator

 public static function overrideStringLengthValidator($p_min, $p_max)
 {
     $validator = new Zend_Validate_StringLength();
     $validator->setMin($p_min);
     $validator->setMax($p_max);
     $validator->setMessage(_("'%value%' is less than %min% characters long"), Zend_Validate_StringLength::TOO_SHORT);
     $validator->setMessage(_("'%value%' is more than %max% characters long"), Zend_Validate_StringLength::TOO_LONG);
     return $validator;
 }
開發者ID:RadioCampusFrance,項目名稱:airtime,代碼行數:9,代碼來源:ValidationTypes.php

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

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

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

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

示例7: _validateUrl

 protected function _validateUrl()
 {
     $val = new Zend_Validate_StringLength();
     $val->setMin(1);
     $val->setMax(255);
     $val->setMessage('Dit is verplicht in te vullen', Zend_Validate_StringLength::TOO_SHORT);
     $val->setMessage('Oops dit is te lang', Zend_Validate_StringLength::TOO_LONG);
     if ($val->isValid($this->_agenda->getUrl())) {
         return true;
     }
     $msg = Sanmax_MessageStack::getInstance('SxModule_Doctor_Agenda');
     $msg->addMessage('url', $validator->getMessages());
     return false;
 }
開發者ID:sonvq,項目名稱:2015_freelance6,代碼行數:14,代碼來源:BaseValidator.php

示例8: init

 /**
  * Overrides init() in Zend_Form
  * 
  * @access public
  * @return void
  */
 public function init()
 {
     // init the parent
     parent::init();
     // set the form's method
     $this->setMethod('post');
     $user = Zend_Auth::getInstance()->getIdentity();
     $oldPasswordValidator = new App_Validate_PasswordExists(array('table' => 'backoffice_users', 'field' => 'password', 'treatment' => 'BackofficeUser::hashPassword', 'userPkValue' => $user->id));
     $complexityValidator = new Zend_Validate_Regex('/^(?=.*\\d)(?=.*[a-z|A-Z]).{7,}$/');
     $complexityValidator->setMessage('The selected password does not meet the required complexity requirements');
     $stringLengthValidator = new Zend_Validate_StringLength();
     $stringLengthValidator->setMin(7);
     $stringLengthValidator->setMessage('Your password must be at least 7 characters long');
     $passwordHistoryValidator = new App_Validate_NoPasswordExists(array('table' => 'password_log', 'field' => 'password', 'treatment' => 'BackofficeUser::hashPassword', 'userPkField' => 'user_id', 'userPkValue' => $user->id));
     $oldPassword = new Zend_Form_Element_Password('old_password');
     $oldPassword->setOptions(array('label' => $this->t('Old password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $oldPasswordValidator)));
     $this->addElement($oldPassword);
     $password = new Zend_Form_Element_Password('password');
     $password->setOptions(array('label' => $this->t('New password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $stringLengthValidator, $complexityValidator, $passwordHistoryValidator)));
     $this->addElement($password);
     $sameAsValidator = new App_Validate_SameAs($password);
     $sameAsValidator->setMessage('The two passwords do not coincide.', App_Validate_SameAs::NOT_THE_SAME);
     $retypeNewPassword = new Zend_Form_Element_Password('retype_new_password');
     $retypeNewPassword->setOptions(array('label' => $this->t('Retype new password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $sameAsValidator)));
     $this->addElement($retypeNewPassword);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setOptions(array('label' => $this->t('Save password'), 'required' => TRUE));
     $this->addElement($submit);
 }
開發者ID:omusico,項目名稱:logica,代碼行數:35,代碼來源:ChangePasswordForm.php

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

示例10: testGetPropertyException

 /**
  * Ensures that the class throws an exception when we try to
  * access a property that doesn't exist as a parameter.
  *
  * @return void
  */
 public function testGetPropertyException()
 {
     $this->_validator->setMessage("Your value is too long", Zend_Validate_StringLength::TOO_LONG);
     $this->assertFalse($this->_validator->isValid('abcdefghij'));
     $messages = $this->_validator->getMessages();
     $this->assertEquals("Your value is too long", $messages[0]);
     try {
         $property = $this->_validator->unknownProperty;
         $this->fail('Expected to catch Zend_Validate_Exception');
     } catch (Zend_Exception $e) {
         $this->assertType('Zend_Validate_Exception', $e, 'Expected exception of type Zend_Validate_Exception, got ' . get_class($e));
         $this->assertEquals("No property exists by the name 'unknownProperty'", $e->getMessage());
     }
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:20,代碼來源:MessageTest.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);
     $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

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

示例13: __construct

 /**
  * Class constructor. Initializes default validators
  *
  * @param integer $accountId
  */
 public function __construct($accountId = null)
 {
     $stringLength = new Zend_Validate_StringLength($this->_stringLengthMin);
     $stringLength->setMessage(self::$messageTooShort, Zend_Validate_StringLength::TOO_SHORT);
     $patternSpecial = new Webbers_Validate_SpecialChar();
     $patternSpecial->setMessage(self::$messageNoSpecial, Webbers_Validate_SpecialChar::NO_SPECIAL_CHAR);
     $patternDigits = new Webbers_Validate_HasDigit();
     $patternDigits->setMessage(self::$messageNoDigit, Webbers_Validate_HasDigit::NO_DIGIT);
     $patternUppercaseLetter = new Webbers_Validate_HasUppercaseLetter();
     $patternUppercaseLetter->setMessage(self::$messageNoUppercaseLetter, Webbers_Validate_HasUppercaseLetter::NO_UPPERCASE_LETTER);
     $patternLowercaseLetter = new Webbers_Validate_HasLowercaseLetter();
     $patternLowercaseLetter->setMessage(self::$messageNoLowercaseLetter, Webbers_Validate_HasLowercaseLetter::NO_LOWERCASE_LETTER);
     $this->isAccountId($accountId);
     $strength = new Webbers_Validate_Password_Strength();
     $strength->setRequiredPoints($this->_requiredPoints)->setMinLength($this->_stringLengthMin)->setMessage(self::$messageTooWeak, Webbers_Validate_Password_Strength::TOO_WEAK);
     $this->addValidator($stringLength)->addValidator($patternSpecial)->addValidator($patternDigits)->addValidator($patternUppercaseLetter)->addValidator($patternLowercaseLetter)->addValidator($this->uniqueValidator, true)->addValidator($strength);
 }
開發者ID:jager,項目名稱:cms,代碼行數:22,代碼來源:Password.php

示例14: __construct

 public function __construct()
 {
     // Validators --------------------------
     $notEmpty = new Zend_Validate_NotEmpty(array(true));
     $notEmpty->setMessage($this->_errorMessages['isEmpy']);
     $digits = new Zend_Validate_Digits();
     $digits->setMessage($this->_errorMessages['digits']);
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessage($this->_errorMessages['emailValidator']);
     $foneValidator = new Zend_Validate_StringLength();
     $foneValidator->setMin(8);
     $foneValidator->setMessage($this->_errorMessages['foneValidator']);
     //--------------------------------------
     $nome = new Zend_Form_Element_Text('nome');
     $nome->setAttrib('class', 'form-control');
     $nome->setRequired(true);
     $nome->addValidator($notEmpty, true);
     //--------------------------------------------------------
     $fone = new Zend_Form_Element_Text('fone');
     $fone->setAttrib('class', 'form-control');
     $fone->setRequired(true);
     $fone->addValidator($notEmpty, true);
     $fone->addValidator($digits, true);
     $fone->addValidator($foneValidator, true);
     //--------------------------------------------------------
     $email = new Zend_Form_Element_Text('email');
     $email->setAttrib('class', 'form-control');
     $email->setRequired(true);
     $email->addValidator($notEmpty, true);
     $email->addValidator($emailValidator, true);
     //--------------------------------------------------------
     $mensagem = new Zend_Form_Element_Textarea('mensagem');
     $mensagem->setAttrib('class', 'form-control');
     $mensagem->setAttrib('cols', 30);
     $mensagem->setAttrib('rows', 10);
     $mensagem->setRequired(true);
     $mensagem->addValidator($notEmpty, true);
     //--------------------------------------------------------
     $this->addElement($nome);
     $this->addElement($fone);
     $this->addElement($email);
     $this->addElement($mensagem);
     $this->setElementDecorators(array('ViewHelper', 'Errors'));
 }
開發者ID:elvisdandrea,項目名稱:esselence,代碼行數:44,代碼來源:FaleConoscoForm.php

示例15: init

 public function init()
 {
     $this->setMethod('post')->setAttrib('id', 'frmProducto');
     // Elemento: Nombre
     $e = new Zend_Form_Element_Text('nombre');
     $e->setLabel('Nombre');
     $e->setAttrib('maxlength', '50');
     $e->setRequired(true);
     $v = new Zend_Validate_StringLength(array('min' => 5, 'max' => 50));
     $v->setMessage("El nombre del producto debe tener debe tener al menos\n            %min% characters. '%value%' no cumple ese requisito", Zend_Validate_StringLength::TOO_SHORT);
     $e->addValidator($v);
     $this->addElement($e);
     // Elemento: Precio
     $e = new Zend_Form_Element_Text('precio');
     $e->setLabel('Precio');
     $e->setRequired(true);
     $v = new Zend_Validate_Between(array('min' => 0.1, 'max' => 9999));
     $e->addValidator($v);
     $v = new Zend_Validate_Float(new Zend_Locale('US'));
     $e->addValidator($v);
     $e->setAttrib('maxlength', '7');
     $this->addElement($e);
     //Elemento: Categoria
     $e = new Zend_Form_Element_Select('id_categoria');
     $e->setLabel('Categoria');
     $_cat = new Application_Model_Categoria();
     $values = $_cat->getComboValues();
     $e->addMultiOption(-1, '--- Categoría ---');
     $e->addMultiOptions($values);
     $this->addElement($e);
     $v = new Zend_Validate_InArray(array_keys($values));
     $e->addValidator($v);
     //Elemento: Fabricante
     $e = new Zend_Form_Element_Select('id_fabricante');
     $e->setLabel('Fabricante');
     $_fab = new Application_Model_Fabricante();
     $values = $_fab->getComboValues();
     $e->addMultiOption(-1, '--- Fabricante ---');
     $e->addMultiOptions($values);
     $this->addElement($e);
     $v = new Zend_Validate_InArray(array_keys($values));
     $e->addValidator($v);
     $this->addElement('submit', 'Enviar');
 }
開發者ID:helmutpacheco,項目名稱:ventas,代碼行數:44,代碼來源:Producto.php


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