本文整理匯總了PHP中Zend\Validator\AbstractValidator::setMessageLength方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractValidator::setMessageLength方法的具體用法?PHP AbstractValidator::setMessageLength怎麽用?PHP AbstractValidator::setMessageLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Validator\AbstractValidator
的用法示例。
在下文中一共展示了AbstractValidator::setMessageLength方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetGetMessageLengthLimitation
public function testSetGetMessageLengthLimitation()
{
Validator\AbstractValidator::setMessageLength(5);
$this->assertEquals(5, Validator\AbstractValidator::getMessageLength());
$valid = new Validator\Between(1, 10);
$this->assertFalse($valid->isValid(24));
$message = current($valid->getMessages());
$this->assertTrue(strlen($message) <= 5);
}
示例2: testMaximumErrorMessageLength
public function testMaximumErrorMessageLength()
{
$this->assertEquals(-1, Validator\ValidatorChain::getMessageLength());
Validator\AbstractValidator::setMessageLength(10);
$this->assertEquals(10, Validator\ValidatorChain::getMessageLength());
$translator = new Translator\Translator('array', array('fooMessage' => 'This is the translated message for %value%'), 'en');
$this->validator->setTranslator($translator);
$this->assertFalse($this->validator->isValid('bar'));
$messages = $this->validator->getMessages();
$this->assertTrue(array_key_exists('fooMessage', $messages));
$this->assertEquals('This is...', $messages['fooMessage']);
}