mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +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:
@@ -20,19 +20,20 @@ abstract class AbstractValidator
|
||||
/** @var string message / dict key to use when an error occurs */
|
||||
protected string $sErrorMessage;
|
||||
|
||||
public function __construct(?string $sErrorMessage)
|
||||
public function __construct(?string $sErrorMessage = null)
|
||||
{
|
||||
if (false === utils::IsNullOrEmptyString($sErrorMessage)) {
|
||||
$this->sErrorMessage = $sErrorMessage;
|
||||
} else {
|
||||
$this->sErrorMessage = self::DEFAULT_ERROR_MESSAGE;
|
||||
}
|
||||
else {
|
||||
$this->sErrorMessage = static::DEFAULT_ERROR_MESSAGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return array<bool,?string> boolean valid for valid / invalid, and error message if invalid
|
||||
* @return string[] list of error messages, empty array if no error
|
||||
*/
|
||||
abstract public function Validate($value): array;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user