-
Notifications
You must be signed in to change notification settings - Fork 4
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
NOPE #1
NOPE #1
Conversation
src/index.ts
Outdated
|
||
default: | ||
//Invalid date | ||
dateStr = 'whoops'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw an error here instead. :)
throw new Error('Invalid Swedish Social Security Number');
Thanks for this PR! However, some scenarios are having the unintended condition returned.
thought should be false since both month and day parts are invalid. however, So, therefore, it seems like the validation for month seems to not work. These are the scenarios used for the check: should eval true ✅ (4/4 tests passed)
_should eval false ❌ (7/9 tests passed)
|
First: The second question in your "Should eval true" and the fourth in the "Should eval false" are the same thing. So I'd like to confirm in which collumn that one is supposed to be, true or false? I'm assuming in true as there is nothing weird about that one. Second: The 5th and 6th "Should eval false" are the exact same thing. This doesn't impact anything except that we're actually only running 8 tests that should be false, not 9. Third: I'll take a look at if I can figure out an easy way to find out if the date is formatted correctly BEFORE we start changing the string. |
There, an update @PatricNox. Also wanted to ask you something else. Shouldn't we move the first line of ssnMask " |
oops, again 😄
the purpose of that regular expression was to clean up the string from any special characters. Though, now when I come to think about it, maybe that's a bad idea and it'll be better to use your condition work. I've tested the new logic, I'd say we go for your approach to check if the string contains a dash, but then we should begin both methods to throw an exception incase there's any other character than a dash and alpha letters within the string.
|
Problem with that is that even in
Really? When I test locally it returns false, as expected 🤔
Instead of throwing an exception, we could use the regex that is currently used to "clean" the string to instead replace anything that isn't number into a
As stated above, I don't think we can delete it, we can only move it further down because EDIT/UPDATE: |
@ThommyDude I agree, returning false makes more sense.
Let's go with that! |
How does this look @PatricNox?
Also, next time we talk about a piece of code... Don't make me make a PR for it, you lazy bum 😂
The code can definitely be improved and/or cleaned a bit. But I'll leave that to you so it fits better with your standards.