Joi validation of dependent fields

Viewed 79

I am trying to set up a Joi schema for the following scenario:

Fields a, b, c. (they all have default value "", so the keys always exist)

Conditions:

When field a is filled, field b must be filled. When field b is filled, field a must be filled. When neither field a nor field b are filled, field c must be filled.

I have tried with Joi's .when, but faced circular dependency. With xor I have faced conflict between exclusive peers.

Any hints on how to approach this?

Thank you!

0 Answers
Related