Is it possible to validate that a boolean is true using Joi? I've tried using allow, valid and invalid without any luck.

1 Answer

Have you tried something like this:

var schema = Joi.boolean().invalid(false); 

Using that schema, the following all populate the error property:

Joi.validate(false, schema); Joi.validate('false', schema); Joi.validate('no', schema); Joi.validate('off', schema); Joi.validate(0, schema); 
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.