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:
Pierre Goiffon
2023-06-28 17:56:04 +02:00
parent d085f15b6d
commit 6cc2d49cd5
20 changed files with 526 additions and 172 deletions

View File

@@ -505,15 +505,33 @@ abstract class Field
return $this;
}
/**
* @param string $sValidatorClassName validator class name, should be one of {@see AbstractValidator} children
* @return $this
* @since 3.1.0 N°6414
*/
final public function RemoveValidatorsOfClass(string $sValidatorClassName)
{
foreach ($this->aValidators as $iKey => $oValue) {
if ($oValue instanceof $sValidatorClassName) {
unset($this->aValidators[$iKey]);
}
}
return $this;
}
/**
* Note : Function is protected as aErrorMessages should not be add from outside
*
* @param string $sErrorMessage
*
* @return $this
*/
protected function AddErrorMessage(string $sErrorMessage)
{
$this->aErrorMessages[] = $sErrorMessage;
return $this;
}