Skip to content

[Request] truthy/falsy case insensitive #1052

@gangstead

Description

@gangstead

Context

In the 10.0.0 release notes it is said that the pre 10.0.0 functionality can be achieved with:

Joi.boolean().truthy('true', 'yes', 1, '1').falsy('false', 'no', 0, '0')

This is not quite the same as the old schema as the new implementation with set doesn't use the insensitive flag when checking for set membership

result.value = (this._inner.truthySet.has(value) ? true
where the previous implementation was case insensitive. A closer approximation to the old behavior would be

Joi.boolean().truthy('true', 'True', 'TRUE', 'yes', 'Yes', 'YES', 1, '1').falsy('false', 'False', 'FALSE', 'no', 'No', 'NO', 0, '0')

but still wouldn't cover bizarre capitalization permutations (TRUe) like the previous behavior.

Would you (Joi team) be open to a PR that makes truthy and falsy values entered be case insensitive? I'm willing to do it but want to make sure it fits into the project's roadmap.

  • joi version: 10.0.0
  • used with (hapi, standalone, ...): hapi

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions