本文整理汇总了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;
}
示例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.')));
}
}
}
示例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());
}