Skip to content

Document the behavior of constraints added to overridden properties in child classes #14784

Closed
@xabbuh

Description

@xabbuh

When one extends a class that defines validation constraints on one property, you are not able to override the validation constraints defined on the parent class by defining the same property with different constraints on the child class. All the defined constraints will be merged (see symfony/symfony#15950).

This is the related part from the Java Language Specification (see symfony/symfony#15950 (comment)):

The effect of constraint declarations is cumulative. Constraints declared on a superclass getter will be validated along with any constraints defined on an overridden version of the getter according to the Java Language Specification visibility rules.
-- 3.3. Inheritance (interface and superclass)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Keep openValidatorhasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions