schema = yup.object({
type: yup.string().required(),
target: yup.object()
.when('type', {
is: 'click',
then: yup.object({
operator: yup.string().matches(/^=$/, 'Operator must be =').required(),
field: yup.string().required(),
value: yup.string().required()
}).required()
})
.when('type', {
is: 'pageview',
then: yup.object({
operator: yup.string().matches(/^wildcard_match/, 'Operator must be =').required(),
field: yup.string().matches(/^path/, 'Field must be path').required(),
value: yup.string().required()
}).required()
})
})