本文整理汇总了PHP中Zend_Validate_StringLength::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_StringLength::getErrors方法的具体用法?PHP Zend_Validate_StringLength::getErrors怎么用?PHP Zend_Validate_StringLength::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_StringLength
的用法示例。
在下文中一共展示了Zend_Validate_StringLength::getErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testGetErrors
/**
* Ensures that the getError() function returns an array of
* message key values corresponding to the messages.
*
* @return void
*/
public function testGetErrors()
{
$inputInvalid = 'abcdefghij';
$this->assertFalse($this->_validator->isValid($inputInvalid));
$messages = $this->_validator->getMessages();
$this->assertEquals("'{$inputInvalid}' is more than 8 characters long", current($messages));
$errors = $this->_validator->getErrors();
$this->assertEquals(Zend_Validate_StringLength::TOO_LONG, current($errors));
}
示例3: isValid
/**
* Validate "syntax" of this field
*
* @throws Setup_Exception_InvalidSchema if {@param $throwException} is set to true
*
* @param $throwException
* @return bool
*/
public function isValid($throwException = false)
{
$isValid = true;
$messages = array();
$nameValidator = new Zend_Validate_StringLength(1, 30);
if (!$nameValidator->isValid($this->name)) {
$isValid = false;
$messages = array_merge($messages, $nameValidator->getErrors());
}
if (!$isValid) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Invalid schema specified for field ' . $this->name . ': ' . print_r($messages, 1));
if ($throwException) {
throw new Setup_Exception_InvalidSchema('Invalid schema specified for field ' . $this->name . ': ' . print_r($messages, 1));
}
}
return $isValid;
}