-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
featureNew functionality or improvementNew functionality or improvement
Milestone
Description
Have a validation case that I'm not sure how to cover.
My existing check is this...
Joi.object().keys({
businessDivision: Joi.number().integer().positive(),
masterProgram: Joi.number().integer().positive(),
profile: Joi.number().integer().positive()
}).xor('businessDivision', 'masterProgram')
Which is fine for ensuring that not both businessDivision and masterProgram are present. But it also has the side effect of requiring at least 1 of them be present.
For my use case both being absent would be just fine.
I can't use .limit(1) because of the unrelated profile key which is optional.
I know I could use .without(...) for a simple case (like above) of just 2 that need to be exclusive but that doesn't expand well to a case where maybe more keys need to be exclusive or but not any required.
Is there a simple way to do this, that also expands to the larger possible key sets as well?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement