本文整理汇总了PHP中Zend_Validate_Between::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Between::getMessages方法的具体用法?PHP Zend_Validate_Between::getMessages怎么用?PHP Zend_Validate_Between::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_Between
的用法示例。
在下文中一共展示了Zend_Validate_Between::getMessages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: betweenAction
public function betweenAction()
{
$v = new Zend_Validate_Between(array('min' => 1, 'max' => 12));
$valor = 15;
if ($v->isValid($valor)) {
echo "{$valor} eh valido";
} else {
echo "{$valor} eh invalido";
$erros = $v->getMessages();
print_r($erros);
}
exit;
}
示例2: setHits
/**
* set the max result hits for this search
*
* @param integer $hits
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setHits($hits = 10)
{
require_once 'Zend/Validate/Between.php';
$validator = new Zend_Validate_Between(0, 1000);
if (!$validator->isValid($hits)) {
$message = $validator->getMessages();
require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
}
$this->_parameters['hits'] = $hits;
return $this;
}
示例3: setImgSize
/**
* Sets img size
*
* @throws Zend_View_Exception
* @param int $imgSize Size of img must be between 1 and 512
* @return Zend_View_Helper_Gravatar
*/
public function setImgSize($imgSize)
{
/**
* @see Zend_Validate_Between
*/
require_once 'Zend/Validate/Between.php';
$betweenValidate = new Zend_Validate_Between(1, 512);
$result = $betweenValidate->isValid($imgSize);
if (!$result) {
/**
* @see Zend_View_Exception
*/
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(current($betweenValidate->getMessages()));
}
$this->_options['imgSize'] = $imgSize;
return $this;
}
示例4: testSetGetMessageLengthLimitation
public function testSetGetMessageLengthLimitation()
{
Zend_Validate::setMessageLength(5);
$this->assertEquals(5, Zend_Validate::getMessageLength());
$valid = new Zend_Validate_Between(1, 10);
$this->assertFalse($valid->isValid(24));
$message = current($valid->getMessages());
$this->assertTrue(strlen($message) <= 5);
}
示例5: testGetMessages
/**
* Ensures that getMessages() returns expected default value
*
* @return void
*/
public function testGetMessages()
{
$validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
$this->assertEquals(array(), $validator->getMessages());
}
示例6: setImgSize
/**
* Sets img size
*
* @throws Zend_View_Exception
* @param int $imgSize Size of img must be between 1 and 512
* @return Zwe_View_Helper_Gravatar
*/
public function setImgSize($imgSize)
{
$betweenValidate = new Zend_Validate_Between(1, 512);
$result = $betweenValidate->isValid($imgSize);
if (!$result) {
throw new Zend_View_Exception(current($betweenValidate->getMessages()));
}
$this->_options['imgSize'] = $imgSize;
return $this;
}
示例7: isValidDocument
public function isValidDocument($file, $max, $allowedTypes)
{
//check size
$validator = new Zend_Validate_Between('1', $max);
if ($validator->isValid($file['size'])) {
} else {
// value failed validation; print reasons
foreach ($validator->getMessages() as $message) {
return array('Error' => 'Document:' . $message);
}
}
//check the type
$this->_fileName = $file['name'];
$return = $this->_checkType($allowedTypes);
if ($return == false) {
return array('Error' => 'Non-allowed type of document.');
}
}