Support setting child errors in custom validators without using validateNested #2683
SharkSharp
started this conversation in
Feature Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
In class-validator, custom validators cannot interact with children errors directly.
The only mechanism that seems to support nested errors is @ValidateNested(), which is not always appropriate for custom validation scenarios.
This makes it hard to represent structured validation failures when a custom constraint needs to validate complex child state.
Motivation
I was considering forking the project and implementing this myself, but wanted to check first if there are any existing plans or preferred approaches.
Proposed Solution
My first thought is to extend defaultMessage (or add a similar method) so it can return a ValidationError structure directly.
Conclusion
I'm willing to implement the new feature, so if a direction is agreed on, I can build it and submit a PR.
Beta Was this translation helpful? Give feedback.
All reactions