Closed lagroms closed 1 year ago
This is likely because you are passing null
. By default .or()
checks for resolved !== undefined
. So either set years: undefined, months: undefined
or override isPresent
-option in the call to
.or('months', 'years', { isPresent: resolved => resolved != undefined })
See docs: https://joi.dev/api/?v=17.8.3#objectorpeers-options
That's correct, except isPresent
should be a function, so .or('months', 'years', { isPresent: (resolved) => resolved !== undefined && resolved !== null })
Yeah, thats right... Updated comment now, Sorry for the typo.
Np, thanks for contributing 🙂
Thanks for the help !
Support plan
Context
How can we help?
I'm trying to require the presence of at least 1 field between "years" and "months". If "months" has a value, then "years" is optional, and the opposite would be true as well. That's the current code that I have using .or() method, but it doesn't seem to work.
I've also tried something like :
but in that case, i'm getting the following error: item added into group months created a dependencies error