Joi: Strict Boolean vs Mostly Boolean

Created on 21 Jul 2016  Â·  2Comments  Â·  Source: sideway/joi

Context

  • _node version_: v4
  • _joi version_: v9
  • _environment_ node
  • _used with_ standalone

    What are you trying to achieve or the steps to reproduce ?

As described in the documentation, the boolean check is not strict - all of these are valid:

Joi.validate(0, Joi.boolean());
Joi.validate(1, Joi.boolean());
Joi.validate('true', Joi.boolean());
Joi.validate('false', Joi.boolean());

Which result you had ?

All of these validate.

What did you expect ?

Would it be possible to have a boolean() and a strictBoolean(), where strictBoolean only validated if the value is true / false?

non issue

Most helpful comment

Joi.boolean().strict() ?

All 2 comments

Joi.boolean().strict() ?

Ah, thanks!

Regards,
Rich

On 21 Jul 2016, 17:07 +0100, Nicolas Morel [email protected], wrote:

Joi.boolean().strict() ?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub (https://github.com/hapijs/joi/issues/954#issuecomment-234302372), or mute the thread (https://github.com/notifications/unsubscribe-auth/AA3XGXOu2UXC0Y53cezQKPA7lM4OkoPYks5qX5lfgaJpZM4JR9Jl).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergibondarenko picture sergibondarenko  Â·  3Comments

n-sviridenko picture n-sviridenko  Â·  3Comments

ashrafkm picture ashrafkm  Â·  3Comments

JbIPS picture JbIPS  Â·  4Comments

kevbook picture kevbook  Â·  4Comments