/** * Adds a validationItem to the internal validation list * @param ValidationItem $validation */ public function addValidation(ValidationItem $validation) { $el = $validation->getElement(); $name = $el->getName(); if (null !== $name) { $this->validationsName[$el->getName(true, true)] = $validation; } $this->validationsInternalName[$validation->getElement()->getInternalName(true)] = $validation; }
/** * @inheritdoc */ public function validate(ValidationItem $validationItem) { $value1 = $validationItem->getValue(); $value2 = $validationItem->findValue($this->sameElement); if ($value2 !== $value1) { $message = new Validation\Message("Fields %_tested-field_% and %_compare-field_% have different values", ["tested-field" => $validationItem->getElement()->getName(true, true), "compare-field" => $this->sameElement], self::DIFFERENT); $validationItem->appendMessage($message); return false; } return true; }