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

Improve Input Validation for Date Handling in getYearsMonthsDaysFromDOB Function #1387

Open
nidhiisinghh opened this issue Jan 10, 2025 · 1 comment

Comments

@nidhiisinghh
Copy link

Description:
The getYearsMonthsDaysFromDOB function in the OpenELIS codebase currently doesn’t handle date input validation well. It needs improvement to:
1. Ensure that only numeric values are accepted in the expected date format (dd/mm/yyyy or mm/dd/yyyy).
2. Provide better user feedback when the input is empty or invalid.
3. Improve error handling when the input format doesn’t match the required structure.

Current Behavior:
• The function accepts a date in the format dd/mm/yyyy or mm/dd/yyyy but doesn’t restrict input to only numeric characters.
• If the input is in an incorrect format (e.g., "abc/xyz/1234" or an empty string), it logs warnings but doesn’t effectively handle the invalid input.
• There’s minimal feedback to the user regarding invalid input.

Expected Behavior:
• The function should only accept numeric values for the day, month, and year parts of the date.
• It should check the input for the correct format and reject invalid or empty inputs.
• If the format is valid, the function should calculate the difference in years, months, and days between the current date and the provided date.

Steps to Reproduce:
1. Call getYearsMonthsDaysFromDOB with invalid date inputs, such as:
• "abc/xyz/1234"
• ""
2. Observe that while warnings are logged, the function does not handle these inputs properly or provide actionable feedback.

Acceptance Criteria:
• The function should properly validate that the input date contains only numeric characters and follows the format dd/mm/yyyy or mm/dd/yyyy.
• Clear and informative warnings should be logged when the input format is invalid.
• The calculation of years, months, and days should work correctly when valid input is provided.

Priority: Medium

@nidhiisinghh
Copy link
Author

I would like to be assigned to this issue.

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

No branches or pull requests

1 participant