Skip to content

Commit

Permalink
Merge pull request #245 from SuffolkLITLab/almax_bug
Browse files Browse the repository at this point in the history
Fixed bug that required alMax
  • Loading branch information
nonprofittechy authored Jan 17, 2024
2 parents 1e2c60c + 27858f6 commit ab998e2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions docassemble/ALToolbox/ThreePartsDate.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,12 @@
// Non-MVP. Make an issue.
// Replace '-' in case it's an ISO date format, (our recommended format).
// JS doesn't play nicely with ISO format.
var min_date = new Date(get_$original_date(field).attr('data-alMin').replace(/-/g, '/'));
var min_attr = get_$original_date(field).attr('data-alMin');
if (!min_attr) {{
// Validation should always succeed if no minimum given
return true;
}}
var min_date = new Date(min_attr.replace(/-/g, '/'));
// Avoid usinig `params`, which could be in many different formats.
// Just get date data from the actual fields
Expand Down Expand Up @@ -538,7 +543,12 @@
}}
// TODO: Catch invalid alMax attr values for devs? Log in console? Make post MVP issue
let max_date = new Date(get_$original_date(field).attr('data-alMax').replace(/-/g, '/'));
let max_attr = get_$original_date(field).attr('data-alMax');
if (!max_attr) {{
// Validation should always succeed if no minimum given
return true;
}}
let max_date = new Date(max_attr.replace(/-/g, '/'));
if ( isNaN(max_date) && is_birthdate(field)) {{
max_date = new Date();
}}
Expand Down

0 comments on commit ab998e2

Please sign in to comment.