-
Notifications
You must be signed in to change notification settings - Fork 87
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
refactor: migrate date validator to ts #749
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.
some preliminary questions
const { selectedDateValidation, customMinDate, customMaxDate } = | ||
dateField.dateValidation || {} | ||
|
||
const isFutureOnly = selectedDateValidation === 'Disallow past 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.
Use the enum DateSelectedValidation
instead of hardcoded string? So this won't erroneously pass even if the enum has changed; but then the frontend is not using that enum...........
Can you also create an issue to track this? Move the enum to shared
and make frontend also rely on that enum instead of DATE_VALIDATION_OPTIONS
in src/public/modules/forms/admin/controllers/edit-fields-modal.client.controller.js
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.
edited + created issue
src/shared/util/date-validation.ts
Outdated
* @param date | ||
* @returns a moment with the date in the format 'DD MMM YYYY' | ||
*/ | ||
export const createMomentFromDateString = (date: string): moment.Moment => { |
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.
is there a reason this is in shared? Seems to be only used in dateValidator.ts and can probably be inlined there.
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.
shifted to inline
also can add typescript tests for all the migrated validators also? do the date one in this PR and do the others in a separate PR ba |
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.
To address karrui's reviews.
0ae2692
to
2c5d369
Compare
@karrui On the tests, I think the plan was to update them after the validator has been migrated and running in production for at least a week |
Don't need migrate them yet, just add new tests in typescript first |
2c5d369
to
49b6c93
Compare
37139c1
to
b1d8260
Compare
b1d8260
to
c7befe4
Compare
@karrui actually I looked at the tests again and I couldn't think of any other test cases to add - any to suggest? |
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.
nice, minor refactors suggested
b7d21cd
to
327744f
Compare
@liangyuanruo for approval |
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.
LGTM - could you also elaborate further why we subtract 12h or add 14h?
Problem
Part of #7
Solution
Improvements
Tests