vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.87k stars 546 forks source link

Custom async props validation #147

Closed filipsobol closed 4 years ago

filipsobol commented 4 years ago

Hi,

With Suspense introduced in Vue 3, is it possible to add support for custom async props validation?

One example use case is similar to the one from Vuelidate documentation:

props: {
    propA: {
        validator: async (value) => {
            const response = await fetch(`/api/unique/${value}`);
            return Boolean(await response.json());
        }
    }
}

Another one would be validate method from vee-validate library, which returns a Promise.

yyx990803 commented 4 years ago

Anything async is inherently complex implementation-wise and it would be best to isolate it in async setup for all possible cases. I don't see enough benefit to justify async validators when this can be done in userland.