You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using DTOs to model and validate my requests using my own bundle (crtl/request-dto-resolver-bundle.
I often have similar DTOs for example for create and update requests where some fields are optional in update but required in create. Using just symfony I can simply extend the class and override validation constriants using loadValidatorMetadata:
It works fine in Symfony. name is required in MyCreateDto but optional in MyUpdateDto.
The problem is that API doc does not pick up loadValidatorMetadata (because its runtime).
So to override the validation constraints I have to override the complete property which is very cumbersome:
crtl
changed the title
[Question]: How to override assertion attributes efficiently in child classes/models
[Question]: How to override assertion attributes or properties in general efficiently in child classes/models
Feb 26, 2025
Version
4.37.1
Question
I am using DTOs to model and validate my requests using my own bundle (crtl/request-dto-resolver-bundle.
I often have similar DTOs for example for create and update requests where some fields are optional in update but required in create. Using just symfony I can simply extend the class and override validation constriants using
loadValidatorMetadata
:It works fine in Symfony.
name
is required inMyCreateDto
but optional inMyUpdateDto
.The problem is that API doc does not pick up loadValidatorMetadata (because its runtime).
So to override the validation constraints I have to override the complete property which is very cumbersome:
Is there a way to extend properties from parent classes in child classes without redefining all the options?
Additional context
No response
The text was updated successfully, but these errors were encountered: