fix: email-address with apostrophe not accepted (#15535)
Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Omar López <[email protected]> Co-authored-by: Amit Sharma <[email protected]>
This commit is contained in:
27 files changed
+77
-42
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
|
||||
export const ZSamlTenantProductInputSchema = z.object({
|
||||
email: z.string().email(),
|
||||
email: emailSchema,
|
||||
});
|
||||
|
||||
export type TSamlTenantProductInputSchema = z.infer<typeof ZSamlTenantProductInputSchema>;
|
||||
@@ -1,5 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
|
||||
const BillingType = z.enum(["PER_BOOKING", "PER_USER"]);
|
||||
const BillingPeriod = z.enum(["MONTHLY", "ANNUALLY"]);
|
||||
|
||||
@@ -9,7 +11,7 @@ export const ZCreateSelfHostedLicenseSchema = z.object({
|
||||
entityPrice: z.number().nonnegative(),
|
||||
billingPeriod: BillingPeriod,
|
||||
overages: z.number().nonnegative(),
|
||||
billingEmail: z.string().email(),
|
||||
billingEmail: emailSchema,
|
||||
});
|
||||
|
||||
export type TCreateSelfHostedLicenseSchema = z.infer<typeof ZCreateSelfHostedLicenseSchema>;
|
||||
@@ -1,8 +1,10 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
|
||||
export const ZResendVerifyEmailSchema = z
|
||||
.object({
|
||||
email: z.string().email(),
|
||||
email: emailSchema,
|
||||
})
|
||||
.optional();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
|
||||
export enum BillingPeriod {
|
||||
@@ -10,7 +11,7 @@ export enum BillingPeriod {
|
||||
export const ZCreateInputSchema = z.object({
|
||||
name: z.string(),
|
||||
slug: z.string().transform((val) => slugify(val.trim())),
|
||||
orgOwnerEmail: z.string().email(),
|
||||
orgOwnerEmail: emailSchema,
|
||||
language: z.string().optional(),
|
||||
seats: z.number().optional(),
|
||||
pricePerSeat: z.number().optional(),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { MAX_NB_INVITES } from "@calcom/lib/constants";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
export const ZInviteMemberInputSchema = z.object({
|
||||
@@ -12,7 +13,7 @@ export const ZInviteMemberInputSchema = z.object({
|
||||
.union([
|
||||
z.string(),
|
||||
z.object({
|
||||
email: z.string().email(),
|
||||
email: emailSchema,
|
||||
role: z.nativeEnum(MembershipRole),
|
||||
}),
|
||||
])
|
||||
@@ -47,7 +48,7 @@ export const ZInviteMemberInputSchema = z.object({
|
||||
.refine(
|
||||
(value) => {
|
||||
if (Array.isArray(value)) {
|
||||
return !value.some((email) => !z.string().email().safeParse(email).success);
|
||||
return !value.some((email) => !emailSchema.safeParse(email).success);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -179,7 +179,9 @@ describe("Invite Member Utils", () => {
|
||||
|
||||
it("should not throw an error if the email is valid", () => {
|
||||
const validEmail = "[email protected]";
|
||||
const validEmailWithApostrophe = "valid'[email protected]";
|
||||
expect(() => checkInputEmailIsValid(validEmail)).not.toThrow();
|
||||
expect(() => checkInputEmailIsValid(validEmailWithApostrophe)).not.toThrow();
|
||||
});
|
||||
});
|
||||
describe("getOrgConnectionInfo", () => {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
|
||||
export const ZResendInvitationInputSchema = z.object({
|
||||
teamId: z.number(),
|
||||
email: z.string().email(),
|
||||
email: emailSchema,
|
||||
language: z.string(),
|
||||
isOrg: z.boolean().default(false),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user