当前位置: 首页>>代码示例>>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;未经允许,请勿转载。