#78394Property and object validators of child classes in STI are ignored
Description
Hi.
In a case, when STI is used it is not possible to override property validators in child classes.
Consider a structure like this:
abstract class Parent {
/**
* @var string
* @validate NotEmpty
*/
protected $title;
/**
* @var string
*/
protected $type;
/* getters, setters and domain logic */
}
class ChildOne {
/**
* @var string
* @validate NotEmpty
* @validate RegularExpression(regularExpression=/^start/)
*/
protected $title;
}
class ChildTwo {
/**
* @var string
* @validate NotEmpty
*/
protected $title;
}
All the TS settings for STI are correct, special TypeConverter exists and objects of corresponding types are correctly created and written into db.
However, for ChildOne only NotEmptyValidator is executed.
If I move the regexp validation statement from child to parent – then it is executed as well.
Expected behavior: execute RegularExpressionValidator for ChildOne.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Related issues 1
History 4
-
Viktor Livakivskyi commented and changed subject
Property validators of child classes in STI are ignoredProperty and object validators of child classes in STI are ignored 10/24/16, 15:07 -
Michael Grundkötter changed Related to #82847 10/24/17, 12:21
-
Christian Eßl changed category 03/04/20, 18:53
-
Stefan Froemken commented and changed status
NewClosed 04/11/25, 14:16I have just tried that in TYPO3 14-dev. I have added two validators into my “Car” model, while I have just one NotEmpty validator in my abstract car model. While calling the show action I get error: “The given subject did not match the pattern”.
So, I’m closing the issue now.
Update: same applies for Domain Model Validators as well – ChildOneValidator will be ignored, while ParentValidator will be executed.