mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-28 04:58:46 +02:00
N°6414 Move existing AbstractSimpleField::Validate impl to custom validators
- LinkedSetField - SelectObjectField - MultipleChoicesField (warning this hierarchy contains non multiple value fields like SelectField !) Also change AbstractValidator::Validate signature : now we are returning an array of error messages, so that we can return multiple ones
This commit is contained in:
@@ -26,12 +26,13 @@ class AbstractSimpleField extends Field
|
||||
|
||||
if (!$bEmpty || $this->GetMandatory()) {
|
||||
foreach ($this->GetValidators() as $oValidator) {
|
||||
[$bIsFieldValid, $sValidationErrorMessage] = $oValidator->Validate($this->GetCurrentValue());
|
||||
$aValidationErrorMessages = $oValidator->Validate($this->GetCurrentValue());
|
||||
|
||||
/** @var bool $bIsFieldValid */
|
||||
if (false === $bIsFieldValid) {
|
||||
if (count($aValidationErrorMessages) > 0) {
|
||||
$this->SetValid(false);
|
||||
$this->AddErrorMessage($sValidationErrorMessage);
|
||||
foreach ($aValidationErrorMessages as $sErrorMessage) {
|
||||
$this->AddErrorMessage($sErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user