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


PHP ValidationResult::combineAnd方法代碼示例

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


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

示例1: validate

 public function validate(ValidationResult $validationResult)
 {
     if ($this->owner->ID > 0 && $this->hasTokenChanged()) {
         $validationResult->combineAnd(new ValidationResult(false, _t('OptimisticLocking.NOSAVEREFRESH', "Save aborted as information has changed. Please refresh the page and try again.", 'User tried to save the dataobject but it had changed since they started working on it.')));
     }
     return $validationResult;
 }
開發者ID:svandragt,項目名稱:silverstripe-optimisticlocking,代碼行數:7,代碼來源:OptimisticLocking.php

示例2: validate

 public function validate(ValidationResult $validationResult)
 {
     if (!$this->owner->Category) {
         $validationResult->combineAnd(new ValidationResult(false, _t('DMSTagExtension.NoCategory', 'You must at least enter a category.')));
     } else {
         $this->owner->Category = trim($this->owner->Category);
         // this is done to prevent the method 'removeTag' in 'DMSDocument' to erase all the tags with same category if no value is defined on the removing Tag
         if (!$this->owner->Value) {
             $this->owner->Value = self::$undefinedValue;
         } else {
             $this->owner->Value = trim($this->owner->Value);
         }
         $query = "SELECT COUNT(*) FROM \"DMSTag\" WHERE \"DMSTag\".\"Category\" LIKE '{$this->owner->Category}' AND \"DMSTag\".\"Value\" LIKE '{$this->owner->Value}'";
         if (DB::query($query)->value()) {
             $validationResult->combineAnd(new ValidationResult(false, _t('DMSTagExtension.CategoryValueNotUnique', 'This tag already exists. Please select it from the multiselect box.')));
         }
     }
 }
開發者ID:tubbs,項目名稱:silverstripe-dms-simple-tags,代碼行數:18,代碼來源:DMSTagExtension.php

示例3: testCombineResults

 /**
  * Test combining validation results together
  */
 public function testCombineResults()
 {
     $result = new ValidationResult();
     $anotherresult = new ValidationResult();
     $yetanotherresult = new ValidationResult();
     $anotherresult->error("Eat with your mouth closed", "EATING101");
     $yetanotherresult->error("You didn't wash your hands", "BECLEAN");
     $this->assertTrue($result->valid());
     $this->assertFalse($anotherresult->valid());
     $this->assertFalse($yetanotherresult->valid());
     $result->combineAnd($anotherresult)->combineAnd($yetanotherresult);
     $this->assertFalse($result->valid());
     $this->assertEquals(array("EATING101" => "Eat with your mouth closed", "BECLEAN" => "You didn't wash your hands"), $result->messageList());
 }
開發者ID:ivoba,項目名稱:silverstripe-framework,代碼行數:17,代碼來源:ValidationExceptionTest.php


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