Skip to content
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

Check isNaN on alMax & use today as birthdate max #248

Merged
merged 5 commits into from
Feb 19, 2024
Merged

Conversation

BryceStevenWilley
Copy link
Contributor

@BryceStevenWilley BryceStevenWilley commented Jan 19, 2024

Finish the code done in #245.

@plocket, is this the direction we want to take? I tried a version using if/elses like you suggested in #245 (comment), but there are more cases than you mentioned there. It was much harder to read IMO, so I didn't continue that.

This does treat invalid alMax / alMin dates as nothing instead of as a NaN Date, which will always be false when compared to other dates with <= and >=. I think means user's wouldn't be able to submit? (part of the testing I need to still do). It's a behavior change, but probably the safest one?

Tested with:

  • no max date
  • invalid max date
  • valid max date
  • no min date
  • invalid min date
  • valid min date
  • no max birthdate
  • invalid max birthdate
  • valid max birthdate (before and after today)

Copy link
Collaborator

@plocket plocket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there are more cases than you mentioned there. It was much harder to read IMO, so I didn't continue that.

No worries. It's been a while since I've looked at that code and what I'm seeing here makes sense to me. I like the new warning. I was hoping to get that in at some point.

This does treat invalid alMax / alMin dates as nothing instead of as a NaN Date, which will always be false when compared to other dates with <= and >=. I think means user's wouldn't be able to submit?

I think by "nothing" you mean an empty string from what I see. isNaN(new Date("")) does === true, so I think it won't get down to the date comparison.

BryceStevenWilley and others added 2 commits January 22, 2024 22:42
* refer to correct date var in `isNaN`
* do similar logic in message functions to prevent errors
* default to showing "birthdate must be in past" when birthdate max is invalid
@BryceStevenWilley BryceStevenWilley marked this pull request as ready for review January 24, 2024 03:39
@BryceStevenWilley
Copy link
Contributor Author

Testing is done! Made a few last fixes for issues I found, but it's ready for review / merging

@nonprofittechy
Copy link
Member

@plocket for you to review when you have a chance i think! You know this code much better

Copy link
Collaborator

@plocket plocket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as far as I can tell! I had one question to confirm my understanding of the flow, but it's not crucial.

docassemble/ALToolbox/ThreePartsDate.py Show resolved Hide resolved
docassemble/ALToolbox/ThreePartsDate.py Show resolved Hide resolved
@nonprofittechy nonprofittechy merged commit 20b5201 into main Feb 19, 2024
4 checks passed
@nonprofittechy nonprofittechy deleted the almax_full branch February 19, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants