Describe your issue here, include schemas and inputs you are validating if needed.
var model = Joi.object().keys({
"Audi": Joi.string().required()
});
Joi.validate({"AUDI":"somevalue"},model) should pass but it fails
It's currently only possible through the use of pattern. I'd argue it's a very uncommon construct and I'd rather wait to see other people with the same need to act on it.
I need this too due to clients sending different cases for header keys: X-Vendor-Ext, X-vendor-ext, x-vendor-ext
Node.js is lower-casing all the headers, I don't think this is a valid use case.
Even then, utilizing a case-insensitive Regex pattern would work or utilizing the string().lowercase() method.
I've definitely found the current interface for dynamic key values to be lacking in the ease-of-use area, but in terms of customization you can do many things with the current implementation. That said, I've not figured out a great way to handle this which could fit within how JS objects work.
The best case that I can think of currently is that having a sibling method to object().pattern() which takes a Joi schema for a String type as the first parameter and tries to match the key there. That said, this would be expensive performance wise (compared to a RegEx) and wouldn't offer anything really different except a an API to construct the key instead of just utilizing RegEx.
It would be great if there was an option in ValidationOptions: e.g. keysAreCaseInsensitive = true|false
Be my guest, PRs are open :)
Low interest and existing workaround. Not worth another config option. If others feel strongly about having this option, we can reconsider.
@hueniverse could you point to the existing workaround?
Most helpful comment
It would be great if there was an option in
ValidationOptions: e.g.keysAreCaseInsensitive = true|false