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
feat: add PersonalDataAndDocumentsDetailed kyc schema #122
Conversation
src/kyc.ts
Outdated
DL = 'DL', | ||
} | ||
|
||
// need [string, ...string[]] types to get zod enums to compile |
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.
i would have preferred using IdentificationDocumentType[]
for both of these, but zod errored out because it doesn't like if you create empty enums I guess. I welcome other ideas of getting this to work though
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; just one question about how the Zod behaves
IdentificationDocumentType, | ||
...IdentificationDocumentType[], | ||
] = [IdentificationDocumentType.IDC, IdentificationDocumentType.DL] | ||
const documentsWithoutBack: [ |
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.
...and the award for most uses of the word "document" in a single expression goes to... 🤣
}), | ||
) | ||
.and( | ||
z |
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.
i assume the linter did this due to the next line's length, but weird to have a line containing only z
here
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.
z
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.
tbh i hate this but yes it's the linter
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.
futzed around for a while trying to get the z some company on that line, to no avail
identificationDocumentType: identificationDocumentTypeWithBackSchema, | ||
identificationDocumentBack: z.string(), | ||
}) | ||
.or( |
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.
If this or
is "selected" by the parser (by identificationDocumentBack
being omitted from the object), does the type of identificationDocumentType
described here (identificationDocumentTypeWithoutBackSchema
) override the more general one set above?
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.
That is, if identificationDocumentBack
is missing, does this setup cause Zod to enforce that identificationDocumentType
be of type identificationDocumentTypeWithoutBackSchema
?
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.
I think so, but to avoid having to reason about this I just dropped it. seems simpler.
src/kyc.ts
Outdated
z.object({ | ||
email: z.string().regex(EMAIL_REGEX), | ||
identificationDocumentFront: z.string(), | ||
identificationDocumentType: identificationDocumentTypeSchema, |
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.
Actually, is this line required, considering both of the options below specify a more narrowly typed version of the same field?
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.
yeah I'll just get rid of it
🎉 This PR is included in version 11.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
similar to #121 but includes more semantics in the zod schemas, in particular:
also more DRY with the existing kyc schema