fix: context doesn't get passed with async custom validator
See original GitHub issue#292 was closed and locked prematurely.
There were two PRs to fix the issue - #296 and #391. #296 was merged, but unfortunately it doesn’t fix the bug that results in context not being passed when validation is performed asynchronously.
If you put async
in the beginning of the following line
https://github.com/typestack/class-validator/blob/e19502578045a74ebd5bfed47f2ab4382aa9cedc/test/functional/validation-options.spec.ts#L949
the test will fail with TypeError: Cannot read property 'isLongerThan' of undefined
.
#391 was based on #296, but it did fix this bug (there was a test case included for that).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Passing context with custom validator · Issue #292 - GitHub
I'm trying to pass a context object on my custom validator but I can't access it from the ValidationError object.
Read more >Pass context this as parameter in custom validator
I trying passing a class property in custom async validator but its value still always undefined when i log it from this validator....
Read more >Model validation in ASP.NET Core MVC | Microsoft Learn
The [ClassicMovie] attribute is a custom validation attribute and the others are built in. Not shown is [ClassicMovieWithClientValidator] ...
Read more >Examples - Final Form Docs
Demonstrates how you can mix synchronous and asynchronous validation patterns at the record-level, by returning errors synchronously, and falling back to an ...
Read more >Vuelidate | A Vue.js model validation library
Simple, lightweight model-based validation for Vue.js. ... Contextified validators; Easy to use with custom validators (e.g. Moment.js); Support for ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I did it by myself. Thanks for your work @dolsem 👍
@Larsrdev I can rebase my fork off the latest master and create a new PR if maintainers express an interest in merging it.