I'm trying to validate that a field is not empty only when either one of two fields is NOT empty using ajv
.
E.g.
{ field1: '', field2: '2', field3: '' } // Invalid
{ field1: '', field2: '', field3: '3' } // Invalid
{ field1: '1', field2: '2', field3: '3' } // Valid
{ field1: '', field2: '', field3: '' } // Valid
I'm trying to use this schema but I don't know how to specify the OR condition.
{
properties: {
field1: {
if: { properties: { field2: { minLength: 1 } },
//or?
then: {
minLength: 1
}
}
}
}
How can I add an OR to this schema?