fix: Exclude the possibility to book events with invalid email addresses (#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
This commit is contained in:
1 parent
a36f2aa871
commit
bfc2b8df34
2 files changed
+10
-2
No files matched your search
@@ -576,3 +576,11 @@ export const allManagedEventTypeProps: { [k in keyof Omit<Prisma.EventTypeSelect
|
||||
export const unlockedManagedEventTypeProps = {
|
||||
...pick(allManagedEventTypeProps, ["locations", "scheduleId", "destinationCalendar"]),
|
||||
};
|
||||
|
||||
// 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) => {
|
||||
const emailRegex = /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i
|
||||
return emailRegex.test(value)
|
||||
}
|
||||
Reference in new issue
Block a user