[Vuejs]-How to validate a field using a custom rule on vee-validate version 3

0👍

Return the promise from your validate function – then vee-validate will wait until it completes before doing anything further. I couldn’t find any reference for this, but I think it should work.

extend('exists', value => {
     return apiService.checkUsername(value)
        .then(response =>
            response.data[0].username == value?true:false;
        )
        .catch(response => alert(response.message));
})

Leave a comment