當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Validate_NotEmpty::getMessages方法代碼示例

本文整理匯總了PHP中Zend_Validate_NotEmpty::getMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Validate_NotEmpty::getMessages方法的具體用法?PHP Zend_Validate_NotEmpty::getMessages怎麽用?PHP Zend_Validate_NotEmpty::getMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Validate_NotEmpty的用法示例。


在下文中一共展示了Zend_Validate_NotEmpty::getMessages方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

 /**
  * @group ZF-11267
  * If we pass in a validator instance that has a preset custom message, this
  * message should be used.
  */
 function testIfCustomMessagesOnValidatorInstancesCanBeUsed()
 {
     // test with a Digits validator
     require_once 'Zend/Validate/Digits.php';
     require_once 'Zend/Validate/NotEmpty.php';
     $data = array('field1' => 'invalid data');
     $customMessage = 'Hey, that\'s not a Digit!!!';
     $validator = new Zend_Validate_Digits();
     $validator->setMessage($customMessage, 'notDigits');
     $this->assertFalse($validator->isValid('foo'), 'standalone validator thinks \'foo\' is a valid digit');
     $messages = $validator->getMessages();
     $this->assertSame($messages['notDigits'], $customMessage, 'stanalone validator does not have custom message');
     $validators = array('field1' => $validator);
     $input = new Zend_Filter_Input(null, $validators, $data);
     $this->assertFalse($input->isValid(), 'invalid input is valid');
     $messages = $input->getMessages();
     $this->assertSame($messages['field1']['notDigits'], $customMessage, 'The custom message is not used');
     // test with a NotEmpty validator
     $data = array('field1' => '');
     $customMessage = 'You should really supply a value...';
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessage($customMessage, 'isEmpty');
     $this->assertFalse($validator->isValid(''), 'standalone validator thinks \'\' is not empty');
     $messages = $validator->getMessages();
     $this->assertSame($messages['isEmpty'], $customMessage, 'stanalone NotEmpty validator does not have custom message');
     $validators = array('field1' => $validator);
     $input = new Zend_Filter_Input(null, $validators, $data);
     $this->assertFalse($input->isValid(), 'invalid input is valid');
     $messages = $input->getMessages();
     $this->assertSame($messages['field1']['isEmpty'], $customMessage, 'For the NotEmpty validator the custom message is not used');
 }
開發者ID:ThorstenSuckow,項目名稱:conjoon,代碼行數:36,代碼來源:InputTest.php

示例2: validateBody

 /**
  * validate the body
  *
  * @param string  $body
  * @return boolean
  */
 private function validateBody($body)
 {
     $notEmptyValidator = new \Zend_Validate_NotEmpty();
     if (!$notEmptyValidator->isValid($body)) {
         $messages = array_values($notEmptyValidator->getMessages());
         $this->addError(new Error('body', $body, $messages));
         return false;
     }
     return true;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:16,代碼來源:Feedback.php

示例3: testGetMessages

 /**
  * Ensures that getMessages() returns expected default value
  *
  * @return void
  */
 public function testGetMessages()
 {
     $this->assertEquals(array(), $this->_validator->getMessages());
 }
開發者ID:jon9872,項目名稱:zend-framework,代碼行數:9,代碼來源:NotEmptyTest.php

示例4: setWhere

 /**
  * set a specific search location
  * examples:
  * +47°54’53.10”, 11° 10’ 56.76”
  * 47°54’53.10;11°10’56.76”
  * 47.914750,11.182533
  * +47.914750 ; +11.1824
  * Darmstadt
  * Berlin
  *
  * @param string $where
  * @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
  */
 public function setWhere($where)
 {
     require_once 'Zend/Validate/NotEmpty.php';
     $validator = new Zend_Validate_NotEmpty();
     if (!$validator->isValid($where)) {
         $message = $validator->getMessages();
         require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
         throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
     }
     $this->_parameters['where'] = $where;
     return $this;
 }
開發者ID:arendasistemasintegrados,項目名稱:mateusleme,代碼行數:25,代碼來源:SearchParameters.php

示例5: isValidData

 /**
  * Validate data.
  * If fails validation, then this method returns false, and
  * getErrors() will return an array of errors that explain why the
  * validation failed.
  *
  * @param array $data
  * @param bool $isPartial
  * @return bool
  */
 public function isValidData(array $data, $isPartial = false)
 {
     $isValid = true;
     // required fields
     if (!$isPartial && count($this->_requiredFields) > 0) {
         $notEmptyValidator = new Zend_Validate_NotEmpty();
         foreach ($this->_requiredFields as $requiredField) {
             if (!$notEmptyValidator->isValid(isset($data[$requiredField]) ? $data[$requiredField] : null)) {
                 $isValid = false;
                 foreach ($notEmptyValidator->getMessages() as $message) {
                     $this->_addError(sprintf('%s: %s', $requiredField, $message));
                 }
             }
         }
     }
     // fields rules
     foreach ($data as $field => $value) {
         if (isset($this->_validators[$field])) {
             /* @var $validator Zend_Validate_Interface */
             $validator = $this->_validators[$field];
             if (!$validator->isValid($value)) {
                 $isValid = false;
                 foreach ($validator->getMessages() as $message) {
                     $this->_addError(sprintf('%s: %s', $field, $message));
                 }
             }
         }
     }
     return $isValid;
 }
開發者ID:hientruong90,項目名稱:ee_14_installer,代碼行數:40,代碼來源:Fields.php

示例6: testZF8767

 /**
  * @ZF-8767
  *
  * @return void
  */
 public function testZF8767()
 {
     $valid = new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING);
     $this->assertFalse($valid->isValid(''));
     $messages = $valid->getMessages();
     $this->assertTrue(array_key_exists('isEmpty', $messages));
     $this->assertContains("can't be empty", $messages['isEmpty']);
 }
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:13,代碼來源:NotEmptyTest.php

示例7: modifyAction

 /**
  * LogBook modify Record action
  *
  */
 function modifyAction()
 {
     $this->view->title = $this->view->translate->_("Logbook: modify record");
     $this->view->wblogbook = new Wblogbook();
     $this->view->amessages = array();
     // ****************************** UPDATE record **********************************
     if ($this->_request->isPost() && $this->_request->getPost('hiddenModify') && $this->_request->getPost('act') == 'update') {
         $logid = trim($this->_request->getPost('logid'));
         // ********************* validate datetime
         $validator_datetime = new MyClass_Validate_Datetime();
         $logDateCreate = trim($this->_request->getPost('logDateCreate'));
         if (!$validator_datetime->isValid($logDateCreate)) {
             $this->view->amessages = array_merge($this->view->amessages, $validator_datetime->getMessages());
         }
         // ********************* validate text
         // This filter returns the input string, with all HTML and PHP tags stripped from it,
         // except those that have been explicitly allowed.
         Zend_Loader::loadClass('Zend_Filter_StripTags');
         // allow :
         // construct($tagsAllowed = null, $attributesAllowed = null, $commentsAllowed = false)
         $strip_tags = new Zend_Filter_StripTags($this->aAllowedTags, $this->aAllowedAttrs, false);
         $logTxt = trim($strip_tags->filter($this->_request->getPost('logTxt')));
         $validator_nonempty = new Zend_Validate_NotEmpty();
         if (!$validator_nonempty->isValid($logTxt)) {
             $this->view->amessages = array_merge($this->view->amessages, $validator_nonempty->getMessages());
         }
         // *** validate pseudo tag BACULA_JOBID
         $validator_baculajobid = new MyClass_Validate_BaculaJobId();
         if (!$validator_baculajobid->isValid($logTxt)) {
             $this->view->amessages = array_merge($this->view->amessages, $validator_baculajobid->getMessages());
         }
         // *** validate pseudo tag LOGBOOK_ID
         $validator_logbookid = new MyClass_Validate_LogbookId();
         if (!$validator_logbookid->isValid($logTxt)) {
             $this->view->amessages = array_merge($this->view->amessages, $validator_logbookid->getMessages());
         }
         // ********************* final
         // update record into database
         if (empty($this->view->amessages)) {
             // validation is OK. add record into logbook
             $table = new wbLogBook();
             $data = array('logDateCreate' => $logDateCreate, 'logDateLast' => date('Y-m-d H:i:s', time()), 'logTypeId' => (int) trim($this->_request->getPost('logTypeId')), 'logTxt' => $logTxt, 'logIsDel' => (int) trim($this->_request->getPost('isdel')));
             $where = $table->getAdapter()->quoteInto('logId = ?', $logid);
             $res = $table->update($data, $where);
             // send email
             if ($res) {
                 $email = new MyClass_SendEmail();
                 // $from_email, $from_name, $to_email, $to_name, $subj, $body
                 $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook Update record'), $this->view->translate->_('Create record :') . ' ' . $data['logDateCreate'] . "\n" . $this->view->translate->_('Update record :') . ' ' . $data['logDateLast'] . "\n" . $this->view->translate->_('Type record :') . ' ' . $data['logTypeId'] . "\n" . $this->view->translate->_("Text :") . "\n-------\n" . $data['logTxt'] . "\n-------\n\n");
             }
             $this->_redirect('/wblogbook/index');
             return;
         }
         // ********************* save user input for correct this
         $this->view->wblogbook->logTxt = $strip_tags->filter($this->_request->getPost('logTxt'));
         $this->view->wblogbook->logTypeId = $this->_request->getPost('logTypeId');
     }
     // ****************************** DELETE record **********************************
     if ($this->_request->isPost() && $this->_request->getPost('hiddenModify') && $this->_request->getPost('act') == 'delete') {
         $logid = trim($this->_request->getPost('logid'));
         $table = new wbLogBook();
         $data = array('logIsDel' => '1');
         $where = $table->getAdapter()->quoteInto('logId = ?', $logid);
         $res = $table->update($data, $where);
         // send email
         if ($res) {
             $email = new MyClass_SendEmail();
             // $from_email, $from_name, $to_email, $to_name, $subj, $body
             $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook Delete record'), $this->view->translate->_("LogId record :") . " " . $logid . "\n");
         }
         $this->_redirect('/wblogbook/index');
         return;
     }
     // ****************************** UNDELETE record **********************************
     if ($this->_request->isPost() && $this->_request->getPost('hiddenModify') && $this->_request->getPost('act') == 'undelete') {
         $logid = trim($this->_request->getPost('logid'));
         $table = new wbLogBook();
         $data = array('logIsDel' => '0');
         $where = $table->getAdapter()->quoteInto('logId = ?', $logid);
         $res = $table->update($data, $where);
         // send email
         if ($res) {
             $email = new MyClass_SendEmail();
             // $from_email, $from_name, $to_email, $to_name, $subj, $body
             $email->mySendEmail($this->view->config->webacula->email->from, $this->view->translate->_('Webacula Logbook'), $this->view->config->webacula->email->to_admin, $this->view->translate->_('Webacula admin'), $this->view->translate->_('Webacula Logbook UnDelete record'), $this->view->translate->_("LogId record :") . " " . $logid . "\n");
         }
         $this->_redirect('/wblogbook/index');
         return;
     }
     // ********************* READ ORIGINAL RECORD from database ****************
     if ($this->_request->isPost()) {
         $logid = trim($this->_request->getPost('logid'));
         // get data from table
         $logs = new wbLogBook();
         $where = $logs->getAdapter()->quoteInto('logId = ?', $logid);
         $row = $logs->fetchRow($where);
//.........這裏部分代碼省略.........
開發者ID:neverstoplwy,項目名稱:contrib-webacula,代碼行數:101,代碼來源:WblogbookController.php

示例8: validateBothMaxIconValuesAreSet

 /**
  * @param  mixed $width
  * @param  mixed $height
  * @return boolean
  */
 private function validateBothMaxIconValuesAreSet($width, $height)
 {
     $maxIconValidator = new NotEmptyValidator(NotEmptyValidator::NULL);
     if ($maxIconValidator->isValid($width) && !$maxIconValidator->isValid($height)) {
         $maxIconValidator->setMessage("'maxiconheight' can not be empty when 'maxiconwidth' is set", NotEmptyValidator::IS_EMPTY);
         $messages = array_values($maxIconValidator->getMessages());
         $this->addError(new Error('maxiconheight', $height, $messages));
         return false;
     }
     if (!$maxIconValidator->isValid($width) && $maxIconValidator->isValid($height)) {
         $maxIconValidator->setMessage("'maxiconwidth' can not be empty when 'maxiconheight' is set", NotEmptyValidator::IS_EMPTY);
         $messages = array_values($maxIconValidator->getMessages());
         $this->addError(new Error('maxiconwidth', $width, $messages));
         return false;
     }
     return true;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:22,代碼來源:Media.php


注:本文中的Zend_Validate_NotEmpty::getMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。