Is it a bad practice to repurpose asyncValidate to integrate the Promise return check library?

I understand what is asyncValidate()provided to support "Is this username used?" and similar use cases where server logic must be executed to validate one or more fields before actually submitting a form.

I am considering the integration of the Yup library created by Joi ( https://github.com/jquense/yup ), as described in detail in this blog post: http://www.davidboyne.co.uk/2016/04/29/redux -form-validation-with-yup.html

I like the declarative yup paradigm, but its function validate()is Promise-return, which, as I thought, I could have awaitin a synchronous function validate()in the Russian Federation, but there is no way to wait for the promised promise before returning from validate(), so this will not work.

It would work with help asyncValidate(), but wouldn’t advise you to repurpose asyncValidatePromise-based validation libraries for integration, how is it?

+4
source share

Source: https://habr.com/ru/post/1659538/


All Articles