reactive_forms icon indicating copy to clipboard operation
reactive_forms copied to clipboard

Implement custom AsyncValidator class

Open morrowyn opened this issue 3 years ago • 3 comments

Hi, I'm trying to create a async validator class, however I noticed there is no interface for it. I want to take this approach, because I want to use getIt dependency injection of my services into the validator.

Validator<T> only have a sync interface. And returning a ValidatorFunction is also a sync interface.

So I'm only left with the docs and implementing local function. Any ideas?

p.s. Love your reactive forms port by the way!

morrowyn avatar May 18 '21 19:05 morrowyn

Hi @morrowyn,

Thanks for using Reactive Forms and for your kind words. As far as I understand about your issue is that you want to create a class that implements an interface like abstract class AsyncValidator. The same way that is implemented the abstract class Validator. Is that what you are suggesting?

Please let me know, and best regards.

joanpablo avatar May 19 '21 12:05 joanpablo

Hi @morrowyn,

Could you please clarify for me if is correct the answer in my first comment? I would like to know if is correct my understanding of what you want with this issue?

Best regards

joanpablo avatar May 29 '21 22:05 joanpablo

Sorry for the late response. But yes, I would like that have an AsyncValidator abstract class

morrowyn avatar Oct 11 '21 11:10 morrowyn

Hi @morrowyn

The newly released version 15.0.0 brings the validators as classes and an AsyncValidator class. Now you can inherit from AsyncValidator to implement a custom validator class.

Thanks for the issue and the contribution.

joanpablo avatar May 26 '23 00:05 joanpablo