-
-
Notifications
You must be signed in to change notification settings - Fork 919
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(date)!: birthdate improvements #2756
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2756 +/- ##
==========================================
+ Coverage 99.93% 99.94% +0.01%
==========================================
Files 2960 2960
Lines 211617 211726 +109
Branches 951 954 +3
==========================================
+ Hits 211473 211604 +131
+ Misses 140 118 -22
Partials 4 4
|
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.
If we want these epoch numbers in error message, we might need to add info about that to the message itself
Min and max have defaults (18 and 80) so you should be allowed to omit one or the other? |
As long as you dont violate the other default. Yes. |
So I would expect |
And that would work, if it wasnt for the year mode. |
I generally think the more specific the error the better. |
Looking at this again in the current docs, it's really weird that the default mode is year and yet the default for min and max are ages. |
Should we change that as well? |
I feel age mode is much more useful. Year mode isn't really much different to between() |
Perhaps to help upgrades we should log a warning if you don't specify mode and min/max are say >1000 (because then you surely meant years not ages). |
Can we see the updated docs in a netlify preview? The defaults still seem a bit confusing. |
Updated
What do you refer to? |
Looking at https://deploy-preview-2756.fakerjs.dev/api/date.html#birthdate
|
I think I might have forgotten to adjust the description after creating the merged signature.
They are sorted alphabetically (per type in the union), I will not change it in the old generation, if we replace it soon anyway. |
Why does the code for mode year need to use the refDate? It seems that should only be needed for age? |
Fixed. Ready for review. |
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.
- Not sure if we should first merge docs: rewrite api-docs generation using ts-morph #2628
IMO that PR doesnt change much regarding this PR. A followup for both displaying/handling multiple signature might though. I'll likely merge the other PR first, because it is bigger. Unless it is delayed a lot. |
I found this branch lying around.
I'm unsure about the contents of the error message:
Max age 25 (599616000000) should be greater than or equal to min age 31 (757382400000).
Max year 1990 (662515200000) should be greater than or equal to min year 2000 (946771200000).
The value in the parenthesis is the epoch timestamp.
Should we remove it?
Max age 25 should be greater than or equal to min age 31.
Max year 1990 should be greater than or equal to min year 2000.
What if min or max is undefined?
Max age 25 should be greater than or equal to min age undefined.
Max year undefined should be greater than or equal to min year 2000.
We could omit/remove the check if the additional checks from #2719 is merged.