Yup .test() async

node v10.24.1
version: 2.0.0
endpointsharetweet
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)
Loading…

no comments

    sign in to comment