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
@@ -3,7 +3,7 @@ import z from "zod";
|
||||
|
||||
import type { ALL_VIEWS } from "@calcom/features/form-builder/FormBuilderFieldsSchema";
|
||||
import type { eventTypeBookingFields } from "@calcom/prisma/zod-utils";
|
||||
import { bookingResponses } from "@calcom/prisma/zod-utils";
|
||||
import { bookingResponses, emailSchemaRefinement } from "@calcom/prisma/zod-utils";
|
||||
|
||||
type EventType = Parameters<typeof preprocess>[0]["eventType"];
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
@@ -114,7 +114,7 @@ function preprocess<T extends z.ZodType>({
|
||||
eventType.bookingFields.forEach((bookingField) => {
|
||||
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);
|
||||
const phoneSchema = isPartialSchema
|
||||
? z.string()
|
||||
: z.string().refine((val) => isValidPhoneNumber(val));
|
||||
|
||||
Reference in new issue
Block a user