joi
joi copied to clipboard
basic validate is failed ...
given schema:
schema = %{
checked: [:string],
indent: [:string],
}
Joi.validate(%{checked: true, indent: 0}, schema)
# => {:ok, %{checked: "true", indent: "0"}}

That's not a bug, Joi.validate/2 doesn't just do the validation. It also does conversions
why conversion ? what's the point ?

When I have time, I will implement a global or local setting to control whether or not to convert this field. But I haven't figured out where to put this setting. Do you have any suggestions?
Do you have any suggestions?
I think the default behavior should be a strict one (no coercion done by default). individually each field could accept a keyword coerce: true to allow coercion for that field. Also, the Joi.validate can accept coerce: true as an option to try to coerce every field that hasn't explicitly defined a coercion option.
Thank you, very good suggestion, I am going to implement this conversion option in the next version.
@y86