const yup = require('yup');
const schema = yup
.object({
red: yup.boolean(),
orange: yup.boolean(),
green: yup.boolean()
})
.test(
'myCustomTest',
null,
(obj) => {
if ( obj.red || obj.orange || obj.green ) {
return true; // everything is fine
}
return new yup.ValidationError(
'Please check at least one checkbox',
null,
'myCustomFieldName'
);
}
);
const validateOptions = { abortEarly: false };
null;