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

OOC-4135: Date validation #188

Merged
merged 5 commits into from
Jun 4, 2024
Merged

OOC-4135: Date validation #188

merged 5 commits into from
Jun 4, 2024

Conversation

masuk-kazi98
Copy link

@masuk-kazi98 masuk-kazi98 commented Jun 4, 2024

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.

  • Update validation messages
  • Added validation to check for real dates
  • Added maxDaysInFuture = 0 to .json

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.

  • Bug fix (non-breaking change which fixes an issue)

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.

  • Updated unit test
  • Verified changes by running locally

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and versioning
  • I have updated the architecture diagrams as per Contribute.md OR added an architectural decision record entry

Copy link

@emilyjevans emilyjevans left a comment

Choose a reason for hiding this comment

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

Pulled this down and tried to break it seems good to me!

@masuk-kazi98 masuk-kazi98 merged commit 31811a8 into develop Jun 4, 2024
1 check passed
@masuk-kazi98 masuk-kazi98 deleted the feat/OOC-4135 branch July 26, 2024 14:49
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.

2 participants