本文整理汇总了PHP中Zend_Validate_StringLength::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_StringLength::isValid方法的具体用法?PHP Zend_Validate_StringLength::isValid怎么用?PHP Zend_Validate_StringLength::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_StringLength
的用法示例。
在下文中一共展示了Zend_Validate_StringLength::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateGroupsRows
public function updateGroupsRows($text, $id, $sportId)
{
if ($this->conn->checkAdmin()) {
$int = new Zend_Validate_Int();
if (!$int->isValid($id)) {
return $this->test;
}
if (!$int->isValid($sportId)) {
return $this->test;
}
$validator = new Zend_Validate_StringLength(2, 100);
if (!$validator->isValid($text)) {
return $this->test;
}
$query = "CALL updateGroups('" . $text . "','" . $id . "');";
$result = $this->conn->insert($query);
$query = "CALL selectGroups( '" . $sportId . "');CALL selectSports( )";
$result->message = $this->conn->multiresultbackArray($query);
return $result;
} else {
$this->test->type = "error";
$this->test->info = "nologin";
return $this->test;
}
}
示例2: _isValid
/**
* @param array $value
* @return boolean indicating is any valid data of interest was passed
*/
protected function _isValid($value)
{
$partialHappened = false;
$isPost = 'post' == $this->getMethodContext();
// comment is set optional for put, required for post
if (isset($value['comment'])) {
$partialHappened = true;
$validate = new Zend_Validate_StringLength(array(1, 1000));
if (!$validate->isValid($value['comment'])) {
$this->_addValidateMessagesAndErrors($validate);
}
} elseif ($isPost) {
$this->_error(self::COMMENT_REQUIRED);
}
// creator_user_id required for post
// creator can't be changed for put, so if not post, then don't bother
// checking this, it will be ignored later
if (isset($value['creator_user_id']) && $isPost) {
$userTable = new Default_Model_DbTable_User();
if (false === current($userTable->find($value['creator_user_id']))) {
$this->_error(self::CREATOR_USER_ID_INVALID, $value['creator_user_id']);
}
} elseif ($isPost) {
$this->_error(self::CREATOR_USER_ID_REQUIRED);
}
return $partialHappened;
}
示例3: _isValid
/**
* @param array $value
* @return boolean indicating is any valid data of interest was passed
*/
protected function _isValid($value)
{
$partialHappened = false;
$isPost = 'post' == $this->getMethodContext();
// validate that the title is set
if (isset($value['title'])) {
$partialHappened = true;
$validate = new Zend_Validate_StringLength(array(1, 100));
if (!$validate->isValid($value['title'])) {
$this->_addValidateMessagesAndErrors($validate);
}
$communityTable = new Default_Model_DbTable_Community();
if ($communityTable->fetchRow(array('title = ?' => $value['title']))) {
$this->_error(self::TITLE_ALREADY_EXISTS, $value['title']);
}
} elseif ($isPost) {
$this->_error(self::TITLE_REQUIRED);
}
// validate that the pic value is reasonable
if (isset($value['pic'])) {
$partialHappened = true;
$validate = new Zend_Validate_StringLength(array(0, 2083));
if (!$validate->isValid($value['pic'])) {
$this->_addValidateMessagesAndErrors($validate);
}
}
return $partialHappened;
}
示例4: 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]);
}
示例5: validate
public function validate($excludeFromValidation = array())
{
if (!in_array('house_name', $excludeFromValidation)) {
$bookhouseSizeValidator = new Zend_Validate_StringLength(3, 20);
if (!$bookhouseSizeValidator->isValid($this->getHouseName())) {
$this->setValidationError('house_name', "Bookhouse name size must bee between 3-20");
}
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: _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;
}
示例10: _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;
}
示例11: 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;
}
示例12: 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;
}
示例13: setSettings
public function setSettings($nImageId, $sUserName, $sDescr)
{
if (is_numeric($nImageId)) {
$aImageSettings = array();
$oStringLenght = new Zend_Validate_StringLength();
$oStringLenght->setMin(0);
$oStringLenght->setMax(50);
if ($oStringLenght->isValid($sUserName)) {
$aImageSettings["user_name"] = $sUserName;
}
$oStringLenght->setMax(100);
if ($oStringLenght->isValid($sDescr)) {
$aImageSettings["descr"] = $sDescr;
}
$oModelImage = new Admin_Model_Image();
if ($oModelImage->saveSettings($nImageId, $aImageSettings)) {
return true;
}
}
return null;
}
示例14: 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;
}
示例15: 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;
}