-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine uppercase with valid #565
Comments
What difference would it make ? |
I would like |
So you want |
So that works for the validation piece, but I lose the functionality of the resulting value being uppercase after validation takes place. Any way to have both? |
@hueniverse do you mind helping me understand that 0b4b45a ? Is it purely optimization ? |
@pon until I find a solution, a hack that works is : Joi.string().insensitive().uppercase().concat(Joi.string().valid(['AA', 'BB', ...])) |
@Marsup - running the code below still returns the non-uppercased value: var Joi = require('joi');
var schema = {
key: Joi.string().insensitive().uppercase().concat(Joi.string().valid(['AA', 'BB']))
};
Joi.validate({ key: 'aa' }, schema, function (err, value) {
// value = { key: 'aa' }
}); |
My bad, thought it was working for a moment. |
No problem - I have a non-Joi workaround for now |
Best I can think of is this : var schema = {
key: Joi.string().uppercase().regex(/^AA|BB$/)
}; |
I came across this as well, and would like to see a solution. Especially for my "lout" documentation I would prefer the combination with valid over regex. |
I'm still thinking about how to lessen the performance impact of such modification. |
I was also expecting As far as 0b4b45a is concerned, after reading the documentation I get the impression that using |
Is it possible to use
string.uppercase()
prior to running through theany.valid()
method?The text was updated successfully, but these errors were encountered: