feat(dui validation): allows DUI value to optionally contain hyphen#13
feat(dui validation): allows DUI value to optionally contain hyphen#13joseaquino wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Hi @joseaquino! Thank you for your contribution, this idea is great, however, I would like to request a few changes:
I do like your approach but since this project is only targetting JS/TS I would like to keep a transparent reference for people using other programming languages in case they need to replicate these algorithms, being said that, I would rather avoid using array helpers.
In order to create an easy and consistent solution, I would suggest you create a function to mask the string based on a regex and then apply the same algorithm.
Apart from that, I would appreciate it if you can include some notes and examples in the readme!
Thanks again, I appreciate you are taking the time to contribute to this project, feel free to reach me out in case you have any questions
|
Hi @joseaquino, it seems @alepaz created a similar feature for NITs, can you please take a look at his approach at #15? |
|
Hey @jonathanpalma I just have a couple question in regards to your first comments:
With regard to your second comment, I took a look at the PR #15 you mentioned and I personally believe that the logic I propose is simpler and more flexible, as the inclusion/exclusion of the const [municipality, birthdate, correlative, verifier] = str.includes('-') ? str.split('-') : splitNIT(str);Also the regex expression proposed in #15 only allows either no hyphens at all or all of the hyphens to be present, this logic is not that flexible as it will not work with a NIT value that has partial hyphens like this |
|
Hi @joseaquino, my apologies for the late reply,
Yes, as I mentioned in my previous comment, I would like this library to work as a reference for people looking for implementing the same solution that are using other languages
I was envisioning a solution that could take Don't get me wrong, I do think your solution is great, however, as I quoted in the previous answer I want this library to be easy to replicate in other languages in order to help developers from different communities.
I guess this statement is subjective to who you ask, if it is a JS developer you might be right, but, again, take into account there might be developers with a different background trying to replicate these algorithms in other languages (in case there isn't any library providing this set of utilities in that specific one)
This is something I would personally like to restrict. It should only allows no hyphens at all Thanks again for contributing, I appreciate your feedback. |
This change allows for the hyphen in the DUI value to be optional, this two examples are valid:
Additionally I simplified the iteration logic of the digits, to make it a little more transparent on what is happening.