-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Refactor proposal] Move optional parameters to options object #1874
Comments
I agree! Let's do it! |
I strongly prefer the options object, personally. It's easier to read and write when there are several options to choose from, and backwards compatibility is built in. I can help out with the typescript side of things. Do you think we should plan a major release in the future where we remove backwards compatibility to the old style? The codebase could get a bit hairy if we maintain backwards compatibility forever, no? |
I'll tag @rubiin in here as well before we continue with this. If he approves, I can work on a PR for one of these as an example. I'll leave the removal of backwards compatibility to the maintainers. For what I've seen in |
Looks good . Lets have more discussion to figure out possible roadmaps |
Sorry for the late response, I seemed to have missed it. I would propose something like the following roadmap; For step 1 either of the two would work for me;
This first step is not mandatory, but in my view way overdue and will make it a lot easier to see which tests are for the old behaviour and which ones are for the new behaviour. Step 2 would be to implement the refactor to one of the validators ( Step 2b would be to add the typings to that in the types repo as well Step 3 would be to write some new guidelines for contributors. In there we can showcase some "golden standard" examples of validator code and test code. This way new contributions are more consistent with our code style Step 4 would be to deprecate the old way in a future major release. Step 5 would be to actually remove the old way in a major release after step 4. In which major release step 4 and 5 will happen I will leave up to the maintainers but I'm in no hurry for that. @rubiin is this what you meant for a roadmap? Or did you want to discuss other aspects? EDIT: Added a new step 3 for contributor guidelines |
Solid plan! I think this will increase the quality and consistency of the code base considerably, and make it easier for contributors to make good quality contributions that are consistent with our code style and easier to review. I would add a step where we write some new guidelines for contributors. In there we can showcase some "golden standard" examples of validator code and test code. |
Yeah this is exactly what i meant |
Good one! I would put that in between the current steps 2 and 3. Will update my comment to reflect that later today |
Great initiative @WikiRik . We should probably use hacktoberfest as an opportunity to advance on this. I am ready to help on this (Participating in coordinating/reviewing or contributing to this initiative) |
I would like to contribute here. Which file(s) would you suggest I work on a part of this issue? :) |
I'll add a column noting which ones have been claimed, but apart from |
Brilliant, will do :). |
@WikiRik I would like to contribute on this as well. Can you assign me one? |
Hey @WikiRik |
|
Cool got it 👍! |
Let's revisit this right after the next release. |
* refactor: change test files to prepare for #1874 * feat(isAfter): allow usage of options object * refactor: improve comparisonDate * refactor: undo breaking change to toDate
The first refactor PR has been merged! @pixelbucket-dev can you rebase your PRs? |
If I am not mistaken the list above is missing the |
You need to provide an algorithm here so it doesn't fall in the scope of this proposal. This proposal only looks at optional parameters |
Changes are done for PR: #2153 |
Currently, there are different ways to define optional parameters.
Many take one options object for these, but some have special string parameters like isIP, which has version. Other combine the two like isAlpha, which takes both a locale string and an options object. This is confusing and not consistent throughout the library.
I propose to unify this so that all optional parameters are put in an options object.
This will affect the following validators;
And the following sanitizers;
The idea is that the changes are backwards compatible, so after implementing this both isAlpha(str, locale, options) and isAlpha(str, options) are supported. There will be a message for the first one that the usage is deprecated and the new syntax would be shown.
I am willing to make all these changes and include tests for backwards compatibility, but I'm also willing to rewrite the README file and take up one of them as an example so the community can contribute to the others.
EDIT: I forgot about the TypeScript types, I'm not very knowledgeable about those so I will need help with those either way.
What do you think about this proposal? Is this a valid change, or are some of these not needed since they only allow one kind of option? Feel free to discuss.
The text was updated successfully, but these errors were encountered: