question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Larsrdevcommented, Feb 24, 2020

I did it by myself. Thanks for your work @dolsem 👍

1reaction
dolsemcommented, Feb 10, 2020

@Larsrdev I can rebase my fork off the latest master and create a new PR if maintainers express an interest in merging it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found