fix: Exclude the possibility to book events with invalid email addresses#9898
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@jemiluv8 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for following the naming conventions! 🙏 |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
| // The PR at https://github.com/colinhacks/zod/pull/2157 addresses this issue and improves email validation | ||
| // I introduced this refinement(to be used with z.email()) as a short term solution until we upgrade to a zod | ||
| // version that will include updates in the above PR. | ||
| export const emailSchemaRefinement = (value: string) => { |
There was a problem hiding this comment.
en email refinement that is based on a regex in a planned update to the zod
built in email validator. Refer to the PR in the comment above for more
details.
The update to the validator improves email validation to catch 4/5 of these
"invalid" emails (In the issue)
| const value = responses[bookingField.name]; | ||
| const stringSchema = z.string(); | ||
| const emailSchema = isPartialSchema ? z.string() : z.string().email(); | ||
| const emailSchema = isPartialSchema ? z.string() : z.string().refine(emailSchemaRefinement); |
There was a problem hiding this comment.
replaced email validation with the refinement
I originally had
z.string().email().refine(emailSchemaRefinement);but felt it was redundant. This refinment is effectively the email validator
so no need to specify the build in zod validator prior to applying the refinement
emrysal
left a comment
There was a problem hiding this comment.
Looks good to me, thank you 👍
…ses (calcom#9898) * Introduce email refinement based on the updated email regex in newer zod versions at https://github.com/colinhacks/zod/pull/2157/files#diff-c54113cf61ec99691748a3890bfbeb00e10efb3f0a76f03a0fd9ec49072e410a * fix import bug * fix lint issue * update emailSchemaRefinement comment to reflect the state of play for the zod fix
What does this PR do?
Fixes #5972 by introducing email refinement on z.string().email() that uses an emailRegex used
in newer versions of the zod package that we currently use
(This is a short term solution and ought to be removed after upgrading the zod npm package).
Refer to https://github.com/colinhacks/zod/pull/2157/files#diff-c54113cf61ec99691748a3890bfbeb00e10efb3f0a76f03a0fd9ec49072e410a
for the email regex used here
https://www.loom.com/share/d309f330f9ba4ffe893300cd5a936088
Fixes #5972
/claim #5972
Type of change
How should this be tested?
For each of the emails below
Mandatory Tasks
Checklist
I haven't read the contributing guideMy code doesn't follow the style guidelines of this projectI haven't commented my code, particularly in hard-to-understand areasI haven't checked if my PR needs changes to the documentationI haven't checked if my changes generate no new warningsI haven't added tests that prove my fix is effective or that my feature worksI haven't checked if new and existing unit tests pass locally with my changes