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

Fix date formats #894

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix date formats #894

wants to merge 3 commits into from

Conversation

timothy-ness
Copy link
Contributor

The validator was not allowing dates including leading 0s e.g. 01/01/2025. It should accept 01/01/2025 or 1/1/2025 (or any combination). The date validator uses joi which is quite rigid in how it validates date format, I considered using joi.alternatives to explicitly check against each possible format however this breaks the error messages. Therefore I opted for this solution which is unideal - it removes a leading 0 if it exists and any 0 after a / character within a string and then validates strictly against the format D/M/YYYY. So it will convert 01/01/2025 to 1/1/2025 before validating. It would also convert 01/01/07 to 1/1/7 which is invalid because of the format of the year (YYYY) anyway.

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