Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(isBefore): allow usage of options object #2088
base: master
Are you sure you want to change the base?
feat(isBefore): allow usage of options object #2088
Changes from 28 commits
5578dad
afda0bd
cad192e
5ba1a43
71102d4
f32d228
7799d9b
5375f17
ae7a8a6
f5b3068
4601b83
50318a3
d7efe27
d8caed7
65a9d71
ded66eb
62c2e22
e907cde
44eda79
de17c53
c145be3
3cfab41
15182ac
0557666
ab6b5ef
0419de3
25f88c4
6a5ec27
587b3ef
05d07ea
daa1abd
23478fd
84151bc
18d652b
57d8945
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Would this work as well? Copied from
isAfter
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.
Nope, that would be a bug :(.
If
comparisonDate
is undefined, the ternary operator will therefore evaluate tooptions
, which would be{ comparisonDate: undefined }
. The latter will break when using insidetoDate
, because it is not a string.Well spotted anyway. This way I realised that I wanted to add tests to cover this scenario.
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.
That's the case in
isAfter
as well right? So we can fix it for both validators in this PR I thinkThere 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.
Yes, that would be the case. I will add a fix.
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.
I've fixed
isAfter
and added tests. FYI, the last test would fail with the old way inisAfter
.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.
I didn't do it for
isAfter
but maybe we can split this up in twoit
blocks? One without arguments (or at least that don't use the old nor new syntax like[]
) and one with arguments. This way it's easier to see what the changes are of the two syntaxes and therefore the scenarios that we need to replicateJust a new idea, so I'm open for feedback and other ideas
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.
Sorry, I am not sure what you mean. Could you give an example with the new syntax?
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.
The new syntax is using the
comparisonDate
in the object.So we would have;
Is that clear?
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.
I've just pushed a proposed refactor to the tests. Let me know what you think :). Here you can also see how important it is to write test cases for all possible scenarios and permutations, ideally upfront, before implementation. That would have made it easier to refactor the implementation to the new syntax. The existing tests probably still lack possible values or permutations. We should probably also test against other nullish values. E.g. should we guard against
null
? Because the code will break ifoptions === null
.