Adding a CancellationToken token parameter to ValueTask functions in the Validators. #225
Closed
emorell96
started this conversation in
New Feature Discussions
Replies: 2 comments 1 reply
-
It would be nice to add CancellationToken to all methods, which return Task |
Beta Was this translation helpful? Give feedback.
1 reply
-
Closed as per the Community Stand-up discussion here: https://youtu.be/N9wMcBP4jtg?t=2889 |
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 think this could be useful specially for more complex custom validations where it might be efficient to be able to cancel the validation if needed.
Right now this is not possible specially in the case where you create something like
MultiValidationBehavior
using your own implementation. SinceMultiValidationBehavior
uses an internal method internally (ValidateNestedAsync
) which is not available to the library users.A workaround this is to use ForceValidate() which returns a ValueTask so it can be awaited like the one above, but the disadvantage of this one is that it doesn't take a CancellationToken meaning that it cannot cancel the validation once underway.
For simple validations it isn't a big deal, but for more complex longer running validations it is.
I think it would be nice to make sure that all awaitable methods in the validators can accept a CancellationToken if possible.
Specially ForceValidate since the underlaying method already accepts it.
What do you all think? I'd appreciate your input.
Beta Was this translation helpful? Give feedback.
All reactions