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

feat: email validator #8

Merged
merged 16 commits into from
Aug 5, 2024
Merged

feat: email validator #8

merged 16 commits into from
Aug 5, 2024

Conversation

zeyu2001
Copy link
Contributor

@zeyu2001 zeyu2001 commented Aug 1, 2024

Email validator that addresses the subdomain validation problem.

packages/validators/src/email/index.ts Outdated Show resolved Hide resolved
packages/validators/src/email/index.ts Outdated Show resolved Hide resolved
packages/validators/src/email/index.ts Outdated Show resolved Hide resolved
packages/validators/src/email/options.ts Outdated Show resolved Hide resolved
Downgrade because current version breaks Markdown formatting with HTML tables
@zeyu2001
Copy link
Contributor Author

zeyu2001 commented Aug 1, 2024

@qin-guan OK now it's just a simple createEmailSchema that returns a ZodSchema<string>

Copy link
Contributor

@qin-guan qin-guan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spaceraccoon plz have a look too!

packages/validators/src/email/options.ts Outdated Show resolved Hide resolved
packages/validators/src/email/options.ts Outdated Show resolved Hide resolved
packages/validators/src/email/schema.ts Outdated Show resolved Hide resolved
packages/validators/src/email/schema.ts Outdated Show resolved Hide resolved
packages/validators/src/email/utils.ts Outdated Show resolved Hide resolved
Comment on lines +19 to +21
domain === whitelisted.domain ||
(whitelisted.includeSubdomains &&
domain.endsWith(`.${whitelisted.domain}`)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nitty: would
whitelisted.includeSubdomains ? domain.endsWith(`.${whitelisted.domain}`) : domain === whitelisted.domain
be somewhat more readable? @qin-guan thots?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spaceraccoon subtle difference in logic here: in the original, if includeSubdomains is true, an exact match of the domain is still allowed (instead of only .${whitelisted.domain})

Copy link
Contributor

@qin-guan qin-guan Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either is okay, just need to document down clearly what the expected / not expected behaviors are and maybe a comment in the code to clarify

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK will clarify the documentation + add comment!

Copy link
Contributor

@qin-guan qin-guan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stylistic changes

packages/validators/src/email/utils.ts Outdated Show resolved Hide resolved
packages/validators/src/email/utils.ts Outdated Show resolved Hide resolved
@zeyu2001 zeyu2001 merged commit 22c0bf0 into develop Aug 5, 2024
5 checks passed
@zeyu2001 zeyu2001 deleted the feat/email branch August 20, 2024 08:21
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.

3 participants