xxxxxxxxxx
import * as yup from 'yup';
const schema = yup.object().shape({
fieldName: yup.string().optional(),
// Add more fields as needed
});
// Validate an object against the schema
const objectToValidate = {
fieldName: 'Some value', // This value is optional
// Add more fields as needed
};
schema.validate(objectToValidate)
.then(valid => console.log(valid))
.catch(errors => console.log(errors));