I am using joi validation in a node project. I have the following need :
I receive an object with the following keys :
- a
- b
- c
- d
All the keys are not required together, but only valid object is if :
- only a and b keys are defined
- only c and d keys are defined
every other case should be invalid
Exemple of valid objects :
{
a:'',
b:''
}
{
c:'',
d:''
}
Exemple of invalid objects :
{
a:'',
b:'',
c:'',
}
{
a:''
}
{
}
...
Thanks in advance
Joi version 17.2.1
I know of two options on how to do this:
Option
1
Option
2
Run some tests: