question: How to make custom validator work with stopAtFirstError? #1818
Unanswered
gtamas
asked this question in
Questions & Answers
Replies: 1 comment
-
Thanks for your question. We have recently started using the discussion tab in order to reserve the issues for actionable items. We prefer that questions are asked in the question and answer section of the discussion tab. I'm converting this into a discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying to...
I'm trying to validate an object type using NestJS / class-validator (v0.13.2) like this.
My validator config:
The problem:
The custom validator gets executed every time, even if input is invalid, so @ValidateNested should catch it and prevent further validation for this property. As far as I know validators are executed in a bottom-to-top order.
If remove the custom validator, I get a proper validation error, but if it's there, I get 500 because it tries to run using the invalid input.
How can I fix this? I want the validation to stop if input data is invalid. The custom validator should only run with valid input.
Btw: is there a way to halt validation globally (not only for the given prop) as soon as some validator fails?
Beta Was this translation helpful? Give feedback.
All reactions