-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fixed bug that required alMax #245
Conversation
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.
Great catch! Sorry you had to run into that. I think it needs one fix before it's ready to go.
if (!max_attr) {{ | ||
// Validation should always succeed if no minimum given | ||
return true; | ||
}} |
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 it's a birthdate field, it still needs to have a max birthdate. I can't make a full suggestion because it would include code that isn't changed, but I imagine would go something like this:
max_date = new Date();
max_attr = ...
if ( max_attr ) {
max_date = max_attr stuff
} else {
if ( !is_birthdate) { return true; }
}
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 don't think that's true? The demo doesn't specify a max date for the example birth date at all (and it doesn't look like there's any available in the DOM.
- Birth date (today is valid): date_of_birth
datatype: BirthDate
required: True
validation messages:
required: This is a custom 'required' message.
If we do want to start enforcing the max attribute for birthdates, what is it supposed to do if there isn't a max attribute on the birthdate? I don't see any good examples of our error handling for developer errors in javascript.
Should it just keep the current PR's code, and have future dates be handled by the python validation, which always happens for Birth dates?
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.
It sounds to me like @plocket forgot that the birthdate validation was happening in Python, not JS. This seems good to merge to me.
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 believe the code in the DOM sets the max date for BirthDate to the current date as the default:
docassemble-ALToolbox/docassemble/ALToolbox/ThreePartsDate.py
Lines 552 to 554 in 27858f6
if ( isNaN(max_date) && is_birthdate(field)) {{ | |
max_date = new Date(); | |
}} |
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.
Gotcha, thanks plocket. I misunderstood what you were saying, and I got a little lost in the code and didn't see the line right below. I'll fix this in a new PR since this was merged too soon.
Finish the code done in #245.
#241 introduced a slight regression that assumed that both
alMax
andalMin
would be present. If they weren't, the JS on the page would stop running, resulting in error messages not going away even when corrected.Tested on my local server and it fixed the problem, removing the errors in my browser console.
Fix #244