-
Notifications
You must be signed in to change notification settings - Fork 7
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
WAITP-1122: Update users import #4459
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.
Just a suggestion to use @tupaia/types
over re-defining the enum options for verified_email
employer: [hasContent], | ||
position: [hasContent], | ||
mobile_number: [], | ||
password: [hasContent], | ||
permission_group: [hasContent], | ||
verified_email: [constructIsEmptyOr(constructIsOneOf(['unverified', 'verified', 'new_user']))], |
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.
verified_email: [constructIsEmptyOr(constructIsOneOf(['unverified', 'verified', 'new_user']))], | |
import { UserAccountSchema } from '@tupaia/types'; | |
... | |
verified_email: [constructIsEmptyOr(constructIsOneOf(UserAccountSchema.verified_email.enum))], |
This is fairly new functionality, but now we have a package called @tupaia/types
which we use to maintain a source of truth about our models. It's possible we could replace all these validators in central-server with ones that use ajv
and @tupaia/types
but for now I think we can at least rely on them for enums and the sort.
@IgorNadj I feel you've got a stronger grasp on using @tupaia/types
that I do, does what I'm suggesting here seem appropriate?
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.
Ah yep, here's an example of using an enum:
https://github.com/beyondessential/tupaia/blob/dev/packages/central-server/src/apiV2/utilities/constructNewRecordValidationRules.js#L292
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, this is great. I have added the type for verified email but the type for gender is just a string so I've left that one as is.
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.
Awesome! Thanks @tcaiger
merge in latest dev before testing
Issue #: WAITP-1122: Update users import (gender and verified)
Changes: