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