当前位置: 首页>>代码示例>>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;未经允许,请勿转载。