Farhan Yaseen Farhan Yaseen - 1 year ago 89
Node.js Question

How boolean can accept empty string

I have scenario i want

subscribe
to accept
true
,
false
and empty string
''

how can i do this

var Register = Joi.object().keys({
company_id: Joi.string().required(),
subscribe: Joi.boolean()
});

Answer Source
subscribe: [Joi.boolean, Joi.string.max(0)]

Took me 3sec of reading the examples on the github documentation.