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.
Description
Fixed existing date validation for DatePartsField components. Updated error messages and also added new date validation to check for real dates (31 Feb, leap years etc). Updated .json file to ensure that maxDaysInFuture is set to 0 which prevents users from entering future dates + update validation message for this.
getStateValueFromValidForm has been updated to check whether the month part of the parsed date has changed. If it has, this means that the date has been validated by JS, so things like 30 feb 2024, the extra days would be carried over and the parsed date would return 1 march 2024. In the case the date has been changed, we'll send a dummy Date object (new Date(0,0,0) (which is equal to 1899-12-31T00:00:00.000Z) to state so that an error message can be set by the getCustomDateValidator. This will check whether the year is 1899, and send the correct error message to joi.validate. If parsed date hasn't changed, the functionality remains the same and will send the parsed date to state to be processed by the schema validators.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce
the testing if necessary.
Checklist: