本文整理汇总了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]);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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]);
}
示例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;
}
示例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;
}
示例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;
}