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