Yup Schemas Are Validated Asynchronously
const numSchema = yup.number();const validator = (val) => {
numSchema.validate(val)
.then(result => {
console.log(result); // it is the value of `val`
return true;
})
.catch(error => {
console.log(error.errors); // array of validation error messages
return false;
});
};validator(5) // => true
validator('what') // => falseLast updated