const { object, string } = require('yup')
var promise1 = value => new Promise(function(resolve, reject) {
setTimeout(function() {
console.log(value);
resolve(!['055555555', '066666666'].includes(value));
}, 500);
});
const contactSchema = object({
phone: string()
.matches(/^[0-9]{9}$/, 'Invalide phone number')
.test(
'myphone',
'phone number is already registered',
async (value) => promise1(value)
),
})
let contact = {
phone: '066666666',
}
await contactSchema.validate(contact)