Issue Bug Closed

#78394Property and object validators of child classes in STI are ignored

Viktor Livakivskyi 10/24/16, 14:40 updated 04/11/25, 14:16

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.