xxxxxxxxxx
password: yup.string().when((password, schema) => {
return password ? schema.required().min(8) : schema;
}),
//Working code
password: yup.string().notRequired().test('password', 'Passwords must be be minimum of 8 characters', function (value) {
if (!!value) {
const schema = yup.string().min(8);
return schema.isValidSync(value);
}
return true;
}),