-
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
Rename multiple keys to another name #1239
Comments
@samueljoli this seems like a poor use of the The reason why I think it is a bad usage is that you would be going through and needing to support every form of case for your string (I think that would be what 2^10 possibilities?) which is going to make this quite slow. Instead I would use the const schema = Joi.object().pattern(/^marketcode$/i, Joi.string()); |
Thought the same thing, except that regexp should be anchored (ie. |
@Marsup @DavidTPate Thanks I wasn't sure about the best way going about it. @DavidTPate Whether I used Also the only problem with using regex is that while it will validate the param it doesn't address my need to be able to still reference the value of that param in it's default camel case form. Using regex would also mean that I would have to make a check for each case (ex |
I'm going to set this issue as a request, taking in a regexp as the source of the rename could make sense indeed. |
@Marsup Sweet! I'll look into implementation. |
This looks a bit complicated for someone not familiar with joi's code, but feel free to try :) |
@Marsup Is there anything in place for me to get a high level walk through the code base? Otherwise I know a core contributor who I can bug to onboard me. |
(just kidding ;) happy to walk through joi code with you) |
@WesTyler 😈 hehehe looking forward to bugging you 🐛 |
Merged the PR. |
Context
What are you trying to achieve or the steps to reproduce ?
I have a need for my params to be case insensitive and would like to implement that by using the
rename
api. It would be nice if I could passrename
a list of keys that whenever present would rename to a default key.Example:
=>
/route?marketCode=191
=>
/route?marketcode=191
=>
/route?MARKETCODE=191
I would expect each permutation to be validated and that in my handler the return value would be...
The text was updated successfully, but these errors were encountered: