Open MubashirWaheed opened 2 years ago
I think if you use anySchema.warning()
the warning will always be thrown so you don't have the conditional behaviour you're looking for. Have you tried using a custom validation for that: https://joi.dev/api/?v=17.7.0#anycustommethod-description?
Support plan
Context
How can we help?
Basically, I want to throw a warning if an optional field is empty. How can this be achieved?
Birth year is an optional field and if it is empty how do I throw a warning?
Relevant question on StackOverflow: https://stackoverflow.com/questions/73415737/how-to-make-joi-warning-on-non-existant-property