@plyaz/types 1.15.2 → 1.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/campaign/index.cjs +3 -3
- package/dist/campaign/index.cjs.map +1 -1
- package/dist/campaign/index.js +3 -3
- package/dist/campaign/index.js.map +1 -1
- package/dist/campaign/types.d.ts +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/user/index.cjs +2 -2
- package/dist/user/index.cjs.map +1 -1
- package/dist/user/index.js +2 -2
- package/dist/user/index.js.map +1 -1
- package/package.json +1 -1
package/dist/user/index.cjs
CHANGED
|
@@ -96,8 +96,8 @@ var athleteProfileSchema = basicProfileSchema.extend({
|
|
|
96
96
|
weight: zod.z.number().min(10, "components.AthleteProfileForm.errors.weightMin" /* WeightMin */).max(500, "components.AthleteProfileForm.errors.weightMax" /* WeightMax */).optional(),
|
|
97
97
|
position: zod.z.string().min(2, "components.AthleteProfileForm.errors.positionMin" /* PositionMin */).max(50, "components.AthleteProfileForm.errors.positionMax" /* PositionMax */).optional(),
|
|
98
98
|
teamName: zod.z.string().min(2, "components.AthleteProfileForm.errors.teamMin" /* TeamMin */).max(100, "components.AthleteProfileForm.errors.teamMax" /* TeamMax */).optional(),
|
|
99
|
-
instagramHandle: zod.z.string().regex(
|
|
100
|
-
tiktokHandle: zod.z.string().regex(
|
|
99
|
+
instagramHandle: zod.z.string().regex(/^$|^@?(?!.*\.\.)(?!.*\.$)[a-zA-Z0-9._]{1,30}$/, "components.AthleteProfileForm.errors.instagramInvalid" /* InstagramInvalid */).optional(),
|
|
100
|
+
tiktokHandle: zod.z.string().regex(/^$|^@?[a-zA-Z0-9][a-zA-Z0-9._]{1,23}$/, "components.AthleteProfileForm.errors.tiktokInvalid" /* TiktokInvalid */).optional(),
|
|
101
101
|
highlightImage: zod.z.union([
|
|
102
102
|
zod.z.instanceof(File).refine(
|
|
103
103
|
(file) => file.size <= 5 * 1024 * 1024,
|
package/dist/user/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/user/enums.ts","../../src/user/schemas.ts"],"names":["BASIC_PROFILE_ERRORS","ATHLETE_PROFILE_ERRORS","z"],"mappings":";;;;;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa,aAAA;AAAA,EACb,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,WAAA,EAAa,aAAA;AAAA,EACb,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,SAAA,EAAW,WAAA;AAAA,EACX,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,UAAA,EAAY,YAAA;AAAA,EACZ,KAAA,EAAO;AACT;AAMO,IAAK,oBAAA,qBAAAA,qBAAAA,KAAL;AAEL,EAAAA,sBAAA,SAAA,CAAA,GAAU,4CAAA;AAE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IACFA,MAAE,MAAA,EAAO;AAAA,IACTA,MAAE,IAAA;AAAK,GACR,EACA,QAAA;AACL,CAAC","file":"index.cjs","sourcesContent":["/**\n * Object containing all supported country codes and their corresponding values.\n * Primarily covers European Union countries plus additional regions.\n */\nexport const COUNTRIES = {\n unitedKingdom: 'unitedKingdom',\n germany: 'germany',\n france: 'france',\n spain: 'spain',\n italy: 'italy',\n netherlands: 'netherlands',\n belgium: 'belgium',\n austria: 'austria',\n switzerland: 'switzerland',\n sweden: 'sweden',\n norway: 'norway',\n denmark: 'denmark',\n finland: 'finland',\n portugal: 'portugal',\n ireland: 'ireland',\n poland: 'poland',\n czechRepublic: 'czechRepublic',\n hungary: 'hungary',\n romania: 'romania',\n bulgaria: 'bulgaria',\n croatia: 'croatia',\n slovenia: 'slovenia',\n slovakia: 'slovakia',\n estonia: 'estonia',\n latvia: 'latvia',\n lithuania: 'lithuania',\n greece: 'greece',\n cyprus: 'cyprus',\n malta: 'malta',\n luxembourg: 'luxembourg',\n other: 'other',\n} as const;\n\n/**\n * Enum containing error message keys for basic profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum BASIC_PROFILE_ERRORS {\n /** Error when name is below minimum length */\n NameMin = 'components.BasicProfileForm.errors.nameMin',\n /** Error when name exceeds maximum length */\n NameMax = 'components.BasicProfileForm.errors.nameMax',\n /** Error when email format is invalid */\n EmailValid = 'components.BasicProfileForm.errors.emailValid',\n /** Error when email is required but not provided */\n EmailRequired = 'components.BasicProfileForm.errors.emailRequired',\n /** Error when country is required but not selected */\n CountryRequired = 'components.BasicProfileForm.errors.countryRequired',\n /** Error when bio exceeds maximum length */\n BioMax = 'components.BasicProfileForm.errors.bioMax',\n /** Error when profile image size exceeds limit */\n ProfileImageSize = 'components.BasicProfileForm.errors.profileImageSize',\n /** Error when profile image type is not supported */\n ProfileImageTypes = 'components.BasicProfileForm.errors.profileImageTypes',\n}\n\n/**\n * Enum containing error message keys for athlete profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum ATHLETE_PROFILE_ERRORS {\n /** Error when date of birth is too recent (maximum age validation) */\n DobMax = 'components.AthleteProfileForm.errors.dobMax',\n /** Error when date of birth is too old (minimum age validation) */\n DobMin = 'components.AthleteProfileForm.errors.dobMin',\n /** Error when height is below minimum value */\n HeightMin = 'components.AthleteProfileForm.errors.heightMin',\n /** Error when height exceeds maximum value */\n HeightMax = 'components.AthleteProfileForm.errors.heightMax',\n /** Error when height format is invalid */\n HeightInvalid = 'components.AthleteProfileForm.errors.heightInvalid',\n /** Error when weight is below minimum value */\n WeightMin = 'components.AthleteProfileForm.errors.weightMin',\n /** Error when weight exceeds maximum value */\n WeightMax = 'components.AthleteProfileForm.errors.weightMax',\n /** Error when weight format is invalid */\n WeightInvalid = 'components.AthleteProfileForm.errors.weightInvalid',\n /** Error when position is below minimum length */\n PositionMin = 'components.AthleteProfileForm.errors.positionMin',\n /** Error when position exceeds maximum length */\n PositionMax = 'components.AthleteProfileForm.errors.positionMax',\n /** Error when team name is below minimum length */\n TeamMin = 'components.AthleteProfileForm.errors.teamMin',\n /** Error when team name exceeds maximum length */\n TeamMax = 'components.AthleteProfileForm.errors.teamMax',\n /** Error when Instagram handle format is invalid */\n InstagramInvalid = 'components.AthleteProfileForm.errors.instagramInvalid',\n /** Error when TikTok handle format is invalid */\n TiktokInvalid = 'components.AthleteProfileForm.errors.tiktokInvalid',\n /** Error when highlight image size exceeds limit */\n HighlightImageSize = 'components.AthleteProfileForm.errors.highlightImageSize',\n /** Error when highlight image type is not supported */\n HighlightImageTypes = 'components.AthleteProfileForm.errors.highlightImageTypes',\n}\n\n/**\n * Type representing all possible error keys for basic profile form validation\n */\nexport type BasicProfileErrorKey = keyof typeof BASIC_PROFILE_ERRORS;\n\n/**\n * Type representing all possible error keys for athlete profile form validation\n */\nexport type AthleteProfileErrorKey = keyof typeof ATHLETE_PROFILE_ERRORS;\n","/* eslint-disable no-magic-numbers */\nimport { z } from 'zod';\nimport { ATHLETE_PROFILE_ERRORS, BASIC_PROFILE_ERRORS } from './enums';\n\nconst MIN_NAME_LENGTH = 2;\nconst MAX_NAME_LENGTH = 50;\nconst MAX_BIO_LENGTH = 275;\n\n/**\n * Zod schema for basic profile form validation.\n * Validates common user profile fields including name, email, country, bio, and profile image.\n */\nexport const basicProfileSchema = z.object({\n name: z\n .string()\n .min(MIN_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMin)\n .max(MAX_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMax),\n email: z\n .string()\n .email(BASIC_PROFILE_ERRORS.EmailValid)\n .min(1, BASIC_PROFILE_ERRORS.EmailRequired),\n country: z.string().min(1, BASIC_PROFILE_ERRORS.CountryRequired),\n bio: z.string().max(MAX_BIO_LENGTH, BASIC_PROFILE_ERRORS.BioMax).optional(),\n profileImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n BASIC_PROFILE_ERRORS.ProfileImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg', 'image/webp'].includes(file.type),\n BASIC_PROFILE_ERRORS.ProfileImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Zod schema for fan profile form validation.\n * Extends basicProfileSchema without additional fields.\n */\nexport const fanProfileSchema = basicProfileSchema.extend({});\n\n/**\n * Zod schema for athlete profile form validation.\n * Extends basicProfileSchema with athlete-specific fields including physical stats,\n * team information, social media handles, and highlight images.\n */\nexport const athleteProfileSchema = basicProfileSchema.extend({\n dateOfBirth: z\n .date()\n .max(new Date(), ATHLETE_PROFILE_ERRORS.DobMax)\n .min(new Date(1900, 0, 1), ATHLETE_PROFILE_ERRORS.DobMin)\n .optional(),\n height: z\n .number()\n .min(50, ATHLETE_PROFILE_ERRORS.HeightMin)\n .max(300, ATHLETE_PROFILE_ERRORS.HeightMax)\n .optional(),\n weight: z\n .number()\n .min(10, ATHLETE_PROFILE_ERRORS.WeightMin)\n .max(500, ATHLETE_PROFILE_ERRORS.WeightMax)\n .optional(),\n position: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.PositionMin)\n .max(50, ATHLETE_PROFILE_ERRORS.PositionMax)\n .optional(),\n teamName: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.TeamMin)\n .max(100, ATHLETE_PROFILE_ERRORS.TeamMax)\n .optional(),\n instagramHandle: z\n .string()\n .regex(/^@?[a-zA-Z0-9._]{1,30}$/, ATHLETE_PROFILE_ERRORS.InstagramInvalid)\n .optional(),\n tiktokHandle: z\n .string()\n .regex(/^@?[a-zA-Z0-9._]{1,24}$/, ATHLETE_PROFILE_ERRORS.TiktokInvalid)\n .optional(),\n highlightImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n ATHLETE_PROFILE_ERRORS.HighlightImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg'].includes(file.type),\n ATHLETE_PROFILE_ERRORS.HighlightImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Type inferred from basicProfileSchema for basic profile form data\n */\nexport type BasicProfileFormData = z.infer<typeof basicProfileSchema>;\n\n/**\n * Type inferred from fanProfileSchema for fan profile form data\n */\nexport type FanProfileFormData = z.infer<typeof fanProfileSchema>;\n\n/**\n * Type inferred from athleteProfileSchema for athlete profile form data\n */\nexport type AthleteProfileFormData = z.infer<typeof athleteProfileSchema>;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/user/enums.ts","../../src/user/schemas.ts"],"names":["BASIC_PROFILE_ERRORS","ATHLETE_PROFILE_ERRORS","z"],"mappings":";;;;;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa,aAAA;AAAA,EACb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A,CACP,MAAA,EAAO,CACP,GAAA,CAAI,wEAAqC,CACzC,GAAA,CAAI,EAAA,EAAA,kDAAA,mBAAsC,CAC1C,QAAA,EAAS;AAAA,EACZ,QAAA,EAAUA,KAAA,CACP,MAAA,EAAO,CACP,GAAA,CAAI,gEAAiC,CACrC,GAAA,CAAI,GAAA,EAAA,8CAAA,eAAmC,CACvC,QAAA,EAAS;AAAA,EACZ,iBAAiBA,KAAA,CACd,MAAA,GACA,KAAA,CAAM,+CAAA,EAAA,uDAAA,yBACN,QAAA,EAAS;AAAA,EACZ,cAAcA,KAAA,CACX,MAAA,GACA,KAAA,CAAM,uCAAA,EAAA,oDAAA,sBACN,QAAA,EAAS;AAAA,EACZ,cAAA,EAAgBA,MACb,KAAA,CAAM;AAAA,IACLA,KAAA,CACG,UAAA,CAAW,IAAI,CAAA,CACf,MAAA;AAAA,MACC,CAAA,IAAA,KAAQ,IAAA,CAAK,IAAA,IAAQ,CAAA,GAAI,IAAA,GAAO,IAAA;AAAA;AAAA,MAAA,yDAAA;AAAA,KAElC,CACC,MAAA;AAAA,MACC,CAAA,IAAA,KAAQ,CAAC,WAAA,EAAa,YAAA,EAAc,WAAW,CAAA,CAAE,QAAA,CAAS,KAAK,IAAI,CAAA;AAAA,MAAA,0DAAA;AAAA,KAErE;AAAA,IACFA,MAAE,MAAA,EAAO;AAAA,IACTA,MAAE,IAAA;AAAK,GACR,EACA,QAAA;AACL,CAAC","file":"index.cjs","sourcesContent":["/**\n * Object containing all supported country codes and their corresponding values.\n * Primarily covers European Union countries plus additional regions.\n */\nexport const COUNTRIES = {\n unitedKingdom: 'unitedKingdom',\n germany: 'germany',\n france: 'france',\n spain: 'spain',\n italy: 'italy',\n netherlands: 'netherlands',\n belgium: 'belgium',\n austria: 'austria',\n switzerland: 'switzerland',\n sweden: 'sweden',\n norway: 'norway',\n denmark: 'denmark',\n finland: 'finland',\n portugal: 'portugal',\n ireland: 'ireland',\n poland: 'poland',\n czechRepublic: 'czechRepublic',\n hungary: 'hungary',\n romania: 'romania',\n bulgaria: 'bulgaria',\n croatia: 'croatia',\n slovenia: 'slovenia',\n slovakia: 'slovakia',\n estonia: 'estonia',\n latvia: 'latvia',\n lithuania: 'lithuania',\n greece: 'greece',\n cyprus: 'cyprus',\n malta: 'malta',\n luxembourg: 'luxembourg',\n other: 'other',\n} as const;\n\n/**\n * Enum containing error message keys for basic profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum BASIC_PROFILE_ERRORS {\n /** Error when name is below minimum length */\n NameMin = 'components.BasicProfileForm.errors.nameMin',\n /** Error when name exceeds maximum length */\n NameMax = 'components.BasicProfileForm.errors.nameMax',\n /** Error when email format is invalid */\n EmailValid = 'components.BasicProfileForm.errors.emailValid',\n /** Error when email is required but not provided */\n EmailRequired = 'components.BasicProfileForm.errors.emailRequired',\n /** Error when country is required but not selected */\n CountryRequired = 'components.BasicProfileForm.errors.countryRequired',\n /** Error when bio exceeds maximum length */\n BioMax = 'components.BasicProfileForm.errors.bioMax',\n /** Error when profile image size exceeds limit */\n ProfileImageSize = 'components.BasicProfileForm.errors.profileImageSize',\n /** Error when profile image type is not supported */\n ProfileImageTypes = 'components.BasicProfileForm.errors.profileImageTypes',\n}\n\n/**\n * Enum containing error message keys for athlete profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum ATHLETE_PROFILE_ERRORS {\n /** Error when date of birth is too recent (maximum age validation) */\n DobMax = 'components.AthleteProfileForm.errors.dobMax',\n /** Error when date of birth is too old (minimum age validation) */\n DobMin = 'components.AthleteProfileForm.errors.dobMin',\n /** Error when height is below minimum value */\n HeightMin = 'components.AthleteProfileForm.errors.heightMin',\n /** Error when height exceeds maximum value */\n HeightMax = 'components.AthleteProfileForm.errors.heightMax',\n /** Error when height format is invalid */\n HeightInvalid = 'components.AthleteProfileForm.errors.heightInvalid',\n /** Error when weight is below minimum value */\n WeightMin = 'components.AthleteProfileForm.errors.weightMin',\n /** Error when weight exceeds maximum value */\n WeightMax = 'components.AthleteProfileForm.errors.weightMax',\n /** Error when weight format is invalid */\n WeightInvalid = 'components.AthleteProfileForm.errors.weightInvalid',\n /** Error when position is below minimum length */\n PositionMin = 'components.AthleteProfileForm.errors.positionMin',\n /** Error when position exceeds maximum length */\n PositionMax = 'components.AthleteProfileForm.errors.positionMax',\n /** Error when team name is below minimum length */\n TeamMin = 'components.AthleteProfileForm.errors.teamMin',\n /** Error when team name exceeds maximum length */\n TeamMax = 'components.AthleteProfileForm.errors.teamMax',\n /** Error when Instagram handle format is invalid */\n InstagramInvalid = 'components.AthleteProfileForm.errors.instagramInvalid',\n /** Error when TikTok handle format is invalid */\n TiktokInvalid = 'components.AthleteProfileForm.errors.tiktokInvalid',\n /** Error when highlight image size exceeds limit */\n HighlightImageSize = 'components.AthleteProfileForm.errors.highlightImageSize',\n /** Error when highlight image type is not supported */\n HighlightImageTypes = 'components.AthleteProfileForm.errors.highlightImageTypes',\n}\n\n/**\n * Type representing all possible error keys for basic profile form validation\n */\nexport type BasicProfileErrorKey = keyof typeof BASIC_PROFILE_ERRORS;\n\n/**\n * Type representing all possible error keys for athlete profile form validation\n */\nexport type AthleteProfileErrorKey = keyof typeof ATHLETE_PROFILE_ERRORS;\n","/* eslint-disable no-magic-numbers */\nimport { z } from 'zod';\nimport { ATHLETE_PROFILE_ERRORS, BASIC_PROFILE_ERRORS } from './enums';\n\nconst MIN_NAME_LENGTH = 2;\nconst MAX_NAME_LENGTH = 50;\nconst MAX_BIO_LENGTH = 275;\n\n/**\n * Zod schema for basic profile form validation.\n * Validates common user profile fields including name, email, country, bio, and profile image.\n */\nexport const basicProfileSchema = z.object({\n name: z\n .string()\n .min(MIN_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMin)\n .max(MAX_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMax),\n email: z\n .string()\n .email(BASIC_PROFILE_ERRORS.EmailValid)\n .min(1, BASIC_PROFILE_ERRORS.EmailRequired),\n country: z.string().min(1, BASIC_PROFILE_ERRORS.CountryRequired),\n bio: z.string().max(MAX_BIO_LENGTH, BASIC_PROFILE_ERRORS.BioMax).optional(),\n profileImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n BASIC_PROFILE_ERRORS.ProfileImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg', 'image/webp'].includes(file.type),\n BASIC_PROFILE_ERRORS.ProfileImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Zod schema for fan profile form validation.\n * Extends basicProfileSchema without additional fields.\n */\nexport const fanProfileSchema = basicProfileSchema.extend({});\n\n/**\n * Zod schema for athlete profile form validation.\n * Extends basicProfileSchema with athlete-specific fields including physical stats,\n * team information, social media handles, and highlight images.\n */\nexport const athleteProfileSchema = basicProfileSchema.extend({\n dateOfBirth: z\n .date()\n .max(new Date(), ATHLETE_PROFILE_ERRORS.DobMax)\n .min(new Date(1900, 0, 1), ATHLETE_PROFILE_ERRORS.DobMin)\n .optional(),\n height: z\n .number()\n .min(50, ATHLETE_PROFILE_ERRORS.HeightMin)\n .max(300, ATHLETE_PROFILE_ERRORS.HeightMax)\n .optional(),\n weight: z\n .number()\n .min(10, ATHLETE_PROFILE_ERRORS.WeightMin)\n .max(500, ATHLETE_PROFILE_ERRORS.WeightMax)\n .optional(),\n position: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.PositionMin)\n .max(50, ATHLETE_PROFILE_ERRORS.PositionMax)\n .optional(),\n teamName: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.TeamMin)\n .max(100, ATHLETE_PROFILE_ERRORS.TeamMax)\n .optional(),\n instagramHandle: z\n .string()\n .regex(/^$|^@?(?!.*\\.\\.)(?!.*\\.$)[a-zA-Z0-9._]{1,30}$/, ATHLETE_PROFILE_ERRORS.InstagramInvalid)\n .optional(),\n tiktokHandle: z\n .string()\n .regex(/^$|^@?[a-zA-Z0-9][a-zA-Z0-9._]{1,23}$/, ATHLETE_PROFILE_ERRORS.TiktokInvalid)\n .optional(),\n highlightImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n ATHLETE_PROFILE_ERRORS.HighlightImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg'].includes(file.type),\n ATHLETE_PROFILE_ERRORS.HighlightImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Type inferred from basicProfileSchema for basic profile form data\n */\nexport type BasicProfileFormData = z.infer<typeof basicProfileSchema>;\n\n/**\n * Type inferred from fanProfileSchema for fan profile form data\n */\nexport type FanProfileFormData = z.infer<typeof fanProfileSchema>;\n\n/**\n * Type inferred from athleteProfileSchema for athlete profile form data\n */\nexport type AthleteProfileFormData = z.infer<typeof athleteProfileSchema>;\n"]}
|
package/dist/user/index.js
CHANGED
|
@@ -94,8 +94,8 @@ var athleteProfileSchema = basicProfileSchema.extend({
|
|
|
94
94
|
weight: z.number().min(10, "components.AthleteProfileForm.errors.weightMin" /* WeightMin */).max(500, "components.AthleteProfileForm.errors.weightMax" /* WeightMax */).optional(),
|
|
95
95
|
position: z.string().min(2, "components.AthleteProfileForm.errors.positionMin" /* PositionMin */).max(50, "components.AthleteProfileForm.errors.positionMax" /* PositionMax */).optional(),
|
|
96
96
|
teamName: z.string().min(2, "components.AthleteProfileForm.errors.teamMin" /* TeamMin */).max(100, "components.AthleteProfileForm.errors.teamMax" /* TeamMax */).optional(),
|
|
97
|
-
instagramHandle: z.string().regex(
|
|
98
|
-
tiktokHandle: z.string().regex(
|
|
97
|
+
instagramHandle: z.string().regex(/^$|^@?(?!.*\.\.)(?!.*\.$)[a-zA-Z0-9._]{1,30}$/, "components.AthleteProfileForm.errors.instagramInvalid" /* InstagramInvalid */).optional(),
|
|
98
|
+
tiktokHandle: z.string().regex(/^$|^@?[a-zA-Z0-9][a-zA-Z0-9._]{1,23}$/, "components.AthleteProfileForm.errors.tiktokInvalid" /* TiktokInvalid */).optional(),
|
|
99
99
|
highlightImage: z.union([
|
|
100
100
|
z.instanceof(File).refine(
|
|
101
101
|
(file) => file.size <= 5 * 1024 * 1024,
|
package/dist/user/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/user/enums.ts","../../src/user/schemas.ts"],"names":["BASIC_PROFILE_ERRORS","ATHLETE_PROFILE_ERRORS"],"mappings":";;;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa,aAAA;AAAA,EACb,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,WAAA,EAAa,aAAA;AAAA,EACb,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,UAAA;AAAA,EACV,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,SAAA,EAAW,WAAA;AAAA,EACX,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,UAAA,EAAY,YAAA;AAAA,EACZ,KAAA,EAAO;AACT;AAMO,IAAK,oBAAA,qBAAAA,qB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CAAA;AAAA,MAAA,0DAAA;AAAA,KAErE;AAAA,IACF,EAAE,MAAA,EAAO;AAAA,IACT,EAAE,IAAA;AAAK,GACR,EACA,QAAA;AACL,CAAC","file":"index.js","sourcesContent":["/**\n * Object containing all supported country codes and their corresponding values.\n * Primarily covers European Union countries plus additional regions.\n */\nexport const COUNTRIES = {\n unitedKingdom: 'unitedKingdom',\n germany: 'germany',\n france: 'france',\n spain: 'spain',\n italy: 'italy',\n netherlands: 'netherlands',\n belgium: 'belgium',\n austria: 'austria',\n switzerland: 'switzerland',\n sweden: 'sweden',\n norway: 'norway',\n denmark: 'denmark',\n finland: 'finland',\n portugal: 'portugal',\n ireland: 'ireland',\n poland: 'poland',\n czechRepublic: 'czechRepublic',\n hungary: 'hungary',\n romania: 'romania',\n bulgaria: 'bulgaria',\n croatia: 'croatia',\n slovenia: 'slovenia',\n slovakia: 'slovakia',\n estonia: 'estonia',\n latvia: 'latvia',\n lithuania: 'lithuania',\n greece: 'greece',\n cyprus: 'cyprus',\n malta: 'malta',\n luxembourg: 'luxembourg',\n other: 'other',\n} as const;\n\n/**\n * Enum containing error message keys for basic profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum BASIC_PROFILE_ERRORS {\n /** Error when name is below minimum length */\n NameMin = 'components.BasicProfileForm.errors.nameMin',\n /** Error when name exceeds maximum length */\n NameMax = 'components.BasicProfileForm.errors.nameMax',\n /** Error when email format is invalid */\n EmailValid = 'components.BasicProfileForm.errors.emailValid',\n /** Error when email is required but not provided */\n EmailRequired = 'components.BasicProfileForm.errors.emailRequired',\n /** Error when country is required but not selected */\n CountryRequired = 'components.BasicProfileForm.errors.countryRequired',\n /** Error when bio exceeds maximum length */\n BioMax = 'components.BasicProfileForm.errors.bioMax',\n /** Error when profile image size exceeds limit */\n ProfileImageSize = 'components.BasicProfileForm.errors.profileImageSize',\n /** Error when profile image type is not supported */\n ProfileImageTypes = 'components.BasicProfileForm.errors.profileImageTypes',\n}\n\n/**\n * Enum containing error message keys for athlete profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum ATHLETE_PROFILE_ERRORS {\n /** Error when date of birth is too recent (maximum age validation) */\n DobMax = 'components.AthleteProfileForm.errors.dobMax',\n /** Error when date of birth is too old (minimum age validation) */\n DobMin = 'components.AthleteProfileForm.errors.dobMin',\n /** Error when height is below minimum value */\n HeightMin = 'components.AthleteProfileForm.errors.heightMin',\n /** Error when height exceeds maximum value */\n HeightMax = 'components.AthleteProfileForm.errors.heightMax',\n /** Error when height format is invalid */\n HeightInvalid = 'components.AthleteProfileForm.errors.heightInvalid',\n /** Error when weight is below minimum value */\n WeightMin = 'components.AthleteProfileForm.errors.weightMin',\n /** Error when weight exceeds maximum value */\n WeightMax = 'components.AthleteProfileForm.errors.weightMax',\n /** Error when weight format is invalid */\n WeightInvalid = 'components.AthleteProfileForm.errors.weightInvalid',\n /** Error when position is below minimum length */\n PositionMin = 'components.AthleteProfileForm.errors.positionMin',\n /** Error when position exceeds maximum length */\n PositionMax = 'components.AthleteProfileForm.errors.positionMax',\n /** Error when team name is below minimum length */\n TeamMin = 'components.AthleteProfileForm.errors.teamMin',\n /** Error when team name exceeds maximum length */\n TeamMax = 'components.AthleteProfileForm.errors.teamMax',\n /** Error when Instagram handle format is invalid */\n InstagramInvalid = 'components.AthleteProfileForm.errors.instagramInvalid',\n /** Error when TikTok handle format is invalid */\n TiktokInvalid = 'components.AthleteProfileForm.errors.tiktokInvalid',\n /** Error when highlight image size exceeds limit */\n HighlightImageSize = 'components.AthleteProfileForm.errors.highlightImageSize',\n /** Error when highlight image type is not supported */\n HighlightImageTypes = 'components.AthleteProfileForm.errors.highlightImageTypes',\n}\n\n/**\n * Type representing all possible error keys for basic profile form validation\n */\nexport type BasicProfileErrorKey = keyof typeof BASIC_PROFILE_ERRORS;\n\n/**\n * Type representing all possible error keys for athlete profile form validation\n */\nexport type AthleteProfileErrorKey = keyof typeof ATHLETE_PROFILE_ERRORS;\n","/* eslint-disable no-magic-numbers */\nimport { z } from 'zod';\nimport { ATHLETE_PROFILE_ERRORS, BASIC_PROFILE_ERRORS } from './enums';\n\nconst MIN_NAME_LENGTH = 2;\nconst MAX_NAME_LENGTH = 50;\nconst MAX_BIO_LENGTH = 275;\n\n/**\n * Zod schema for basic profile form validation.\n * Validates common user profile fields including name, email, country, bio, and profile image.\n */\nexport const basicProfileSchema = z.object({\n name: z\n .string()\n .min(MIN_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMin)\n .max(MAX_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMax),\n email: z\n .string()\n .email(BASIC_PROFILE_ERRORS.EmailValid)\n .min(1, BASIC_PROFILE_ERRORS.EmailRequired),\n country: z.string().min(1, BASIC_PROFILE_ERRORS.CountryRequired),\n bio: z.string().max(MAX_BIO_LENGTH, BASIC_PROFILE_ERRORS.BioMax).optional(),\n profileImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n BASIC_PROFILE_ERRORS.ProfileImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg', 'image/webp'].includes(file.type),\n BASIC_PROFILE_ERRORS.ProfileImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Zod schema for fan profile form validation.\n * Extends basicProfileSchema without additional fields.\n */\nexport const fanProfileSchema = basicProfileSchema.extend({});\n\n/**\n * Zod schema for athlete profile form validation.\n * Extends basicProfileSchema with athlete-specific fields including physical stats,\n * team information, social media handles, and highlight images.\n */\nexport const athleteProfileSchema = basicProfileSchema.extend({\n dateOfBirth: z\n .date()\n .max(new Date(), ATHLETE_PROFILE_ERRORS.DobMax)\n .min(new Date(1900, 0, 1), ATHLETE_PROFILE_ERRORS.DobMin)\n .optional(),\n height: z\n .number()\n .min(50, ATHLETE_PROFILE_ERRORS.HeightMin)\n .max(300, ATHLETE_PROFILE_ERRORS.HeightMax)\n .optional(),\n weight: z\n .number()\n .min(10, ATHLETE_PROFILE_ERRORS.WeightMin)\n .max(500, ATHLETE_PROFILE_ERRORS.WeightMax)\n .optional(),\n position: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.PositionMin)\n .max(50, ATHLETE_PROFILE_ERRORS.PositionMax)\n .optional(),\n teamName: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.TeamMin)\n .max(100, ATHLETE_PROFILE_ERRORS.TeamMax)\n .optional(),\n instagramHandle: z\n .string()\n .regex(/^@?[a-zA-Z0-9._]{1,30}$/, ATHLETE_PROFILE_ERRORS.InstagramInvalid)\n .optional(),\n tiktokHandle: z\n .string()\n .regex(/^@?[a-zA-Z0-9._]{1,24}$/, ATHLETE_PROFILE_ERRORS.TiktokInvalid)\n .optional(),\n highlightImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n ATHLETE_PROFILE_ERRORS.HighlightImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg'].includes(file.type),\n ATHLETE_PROFILE_ERRORS.HighlightImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Type inferred from basicProfileSchema for basic profile form data\n */\nexport type BasicProfileFormData = z.infer<typeof basicProfileSchema>;\n\n/**\n * Type inferred from fanProfileSchema for fan profile form data\n */\nexport type FanProfileFormData = z.infer<typeof fanProfileSchema>;\n\n/**\n * Type inferred from athleteProfileSchema for athlete profile form data\n */\nexport type AthleteProfileFormData = z.infer<typeof athleteProfileSchema>;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/user/enums.ts","../../src/user/schemas.ts"],"names":["BASIC_PROFILE_ERRORS","ATHLETE_PROFILE_ERRORS"],"mappings":";;;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,KAAA,EAAO,OAAA;AAAA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EACZ,QAAA,EAAU,CAAA,CACP,MAAA,EAAO,CACP,GAAA,CAAI,wEAAqC,CACzC,GAAA,CAAI,EAAA,EAAA,kDAAA,mBAAsC,CAC1C,QAAA,EAAS;AAAA,EACZ,QAAA,EAAU,CAAA,CACP,MAAA,EAAO,CACP,GAAA,CAAI,gEAAiC,CACrC,GAAA,CAAI,GAAA,EAAA,8CAAA,eAAmC,CACvC,QAAA,EAAS;AAAA,EACZ,iBAAiB,CAAA,CACd,MAAA,GACA,KAAA,CAAM,+CAAA,EAAA,uDAAA,yBACN,QAAA,EAAS;AAAA,EACZ,cAAc,CAAA,CACX,MAAA,GACA,KAAA,CAAM,uCAAA,EAAA,oDAAA,sBACN,QAAA,EAAS;AAAA,EACZ,cAAA,EAAgB,EACb,KAAA,CAAM;AAAA,IACL,CAAA,CACG,UAAA,CAAW,IAAI,CAAA,CACf,MAAA;AAAA,MACC,CAAA,IAAA,KAAQ,IAAA,CAAK,IAAA,IAAQ,CAAA,GAAI,IAAA,GAAO,IAAA;AAAA;AAAA,MAAA,yDAAA;AAAA,KAElC,CACC,MAAA;AAAA,MACC,CAAA,IAAA,KAAQ,CAAC,WAAA,EAAa,YAAA,EAAc,WAAW,CAAA,CAAE,QAAA,CAAS,KAAK,IAAI,CAAA;AAAA,MAAA,0DAAA;AAAA,KAErE;AAAA,IACF,EAAE,MAAA,EAAO;AAAA,IACT,EAAE,IAAA;AAAK,GACR,EACA,QAAA;AACL,CAAC","file":"index.js","sourcesContent":["/**\n * Object containing all supported country codes and their corresponding values.\n * Primarily covers European Union countries plus additional regions.\n */\nexport const COUNTRIES = {\n unitedKingdom: 'unitedKingdom',\n germany: 'germany',\n france: 'france',\n spain: 'spain',\n italy: 'italy',\n netherlands: 'netherlands',\n belgium: 'belgium',\n austria: 'austria',\n switzerland: 'switzerland',\n sweden: 'sweden',\n norway: 'norway',\n denmark: 'denmark',\n finland: 'finland',\n portugal: 'portugal',\n ireland: 'ireland',\n poland: 'poland',\n czechRepublic: 'czechRepublic',\n hungary: 'hungary',\n romania: 'romania',\n bulgaria: 'bulgaria',\n croatia: 'croatia',\n slovenia: 'slovenia',\n slovakia: 'slovakia',\n estonia: 'estonia',\n latvia: 'latvia',\n lithuania: 'lithuania',\n greece: 'greece',\n cyprus: 'cyprus',\n malta: 'malta',\n luxembourg: 'luxembourg',\n other: 'other',\n} as const;\n\n/**\n * Enum containing error message keys for basic profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum BASIC_PROFILE_ERRORS {\n /** Error when name is below minimum length */\n NameMin = 'components.BasicProfileForm.errors.nameMin',\n /** Error when name exceeds maximum length */\n NameMax = 'components.BasicProfileForm.errors.nameMax',\n /** Error when email format is invalid */\n EmailValid = 'components.BasicProfileForm.errors.emailValid',\n /** Error when email is required but not provided */\n EmailRequired = 'components.BasicProfileForm.errors.emailRequired',\n /** Error when country is required but not selected */\n CountryRequired = 'components.BasicProfileForm.errors.countryRequired',\n /** Error when bio exceeds maximum length */\n BioMax = 'components.BasicProfileForm.errors.bioMax',\n /** Error when profile image size exceeds limit */\n ProfileImageSize = 'components.BasicProfileForm.errors.profileImageSize',\n /** Error when profile image type is not supported */\n ProfileImageTypes = 'components.BasicProfileForm.errors.profileImageTypes',\n}\n\n/**\n * Enum containing error message keys for athlete profile form validation.\n * Contains localized error message keys that map to translation strings.\n */\nexport enum ATHLETE_PROFILE_ERRORS {\n /** Error when date of birth is too recent (maximum age validation) */\n DobMax = 'components.AthleteProfileForm.errors.dobMax',\n /** Error when date of birth is too old (minimum age validation) */\n DobMin = 'components.AthleteProfileForm.errors.dobMin',\n /** Error when height is below minimum value */\n HeightMin = 'components.AthleteProfileForm.errors.heightMin',\n /** Error when height exceeds maximum value */\n HeightMax = 'components.AthleteProfileForm.errors.heightMax',\n /** Error when height format is invalid */\n HeightInvalid = 'components.AthleteProfileForm.errors.heightInvalid',\n /** Error when weight is below minimum value */\n WeightMin = 'components.AthleteProfileForm.errors.weightMin',\n /** Error when weight exceeds maximum value */\n WeightMax = 'components.AthleteProfileForm.errors.weightMax',\n /** Error when weight format is invalid */\n WeightInvalid = 'components.AthleteProfileForm.errors.weightInvalid',\n /** Error when position is below minimum length */\n PositionMin = 'components.AthleteProfileForm.errors.positionMin',\n /** Error when position exceeds maximum length */\n PositionMax = 'components.AthleteProfileForm.errors.positionMax',\n /** Error when team name is below minimum length */\n TeamMin = 'components.AthleteProfileForm.errors.teamMin',\n /** Error when team name exceeds maximum length */\n TeamMax = 'components.AthleteProfileForm.errors.teamMax',\n /** Error when Instagram handle format is invalid */\n InstagramInvalid = 'components.AthleteProfileForm.errors.instagramInvalid',\n /** Error when TikTok handle format is invalid */\n TiktokInvalid = 'components.AthleteProfileForm.errors.tiktokInvalid',\n /** Error when highlight image size exceeds limit */\n HighlightImageSize = 'components.AthleteProfileForm.errors.highlightImageSize',\n /** Error when highlight image type is not supported */\n HighlightImageTypes = 'components.AthleteProfileForm.errors.highlightImageTypes',\n}\n\n/**\n * Type representing all possible error keys for basic profile form validation\n */\nexport type BasicProfileErrorKey = keyof typeof BASIC_PROFILE_ERRORS;\n\n/**\n * Type representing all possible error keys for athlete profile form validation\n */\nexport type AthleteProfileErrorKey = keyof typeof ATHLETE_PROFILE_ERRORS;\n","/* eslint-disable no-magic-numbers */\nimport { z } from 'zod';\nimport { ATHLETE_PROFILE_ERRORS, BASIC_PROFILE_ERRORS } from './enums';\n\nconst MIN_NAME_LENGTH = 2;\nconst MAX_NAME_LENGTH = 50;\nconst MAX_BIO_LENGTH = 275;\n\n/**\n * Zod schema for basic profile form validation.\n * Validates common user profile fields including name, email, country, bio, and profile image.\n */\nexport const basicProfileSchema = z.object({\n name: z\n .string()\n .min(MIN_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMin)\n .max(MAX_NAME_LENGTH, BASIC_PROFILE_ERRORS.NameMax),\n email: z\n .string()\n .email(BASIC_PROFILE_ERRORS.EmailValid)\n .min(1, BASIC_PROFILE_ERRORS.EmailRequired),\n country: z.string().min(1, BASIC_PROFILE_ERRORS.CountryRequired),\n bio: z.string().max(MAX_BIO_LENGTH, BASIC_PROFILE_ERRORS.BioMax).optional(),\n profileImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n BASIC_PROFILE_ERRORS.ProfileImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg', 'image/webp'].includes(file.type),\n BASIC_PROFILE_ERRORS.ProfileImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Zod schema for fan profile form validation.\n * Extends basicProfileSchema without additional fields.\n */\nexport const fanProfileSchema = basicProfileSchema.extend({});\n\n/**\n * Zod schema for athlete profile form validation.\n * Extends basicProfileSchema with athlete-specific fields including physical stats,\n * team information, social media handles, and highlight images.\n */\nexport const athleteProfileSchema = basicProfileSchema.extend({\n dateOfBirth: z\n .date()\n .max(new Date(), ATHLETE_PROFILE_ERRORS.DobMax)\n .min(new Date(1900, 0, 1), ATHLETE_PROFILE_ERRORS.DobMin)\n .optional(),\n height: z\n .number()\n .min(50, ATHLETE_PROFILE_ERRORS.HeightMin)\n .max(300, ATHLETE_PROFILE_ERRORS.HeightMax)\n .optional(),\n weight: z\n .number()\n .min(10, ATHLETE_PROFILE_ERRORS.WeightMin)\n .max(500, ATHLETE_PROFILE_ERRORS.WeightMax)\n .optional(),\n position: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.PositionMin)\n .max(50, ATHLETE_PROFILE_ERRORS.PositionMax)\n .optional(),\n teamName: z\n .string()\n .min(2, ATHLETE_PROFILE_ERRORS.TeamMin)\n .max(100, ATHLETE_PROFILE_ERRORS.TeamMax)\n .optional(),\n instagramHandle: z\n .string()\n .regex(/^$|^@?(?!.*\\.\\.)(?!.*\\.$)[a-zA-Z0-9._]{1,30}$/, ATHLETE_PROFILE_ERRORS.InstagramInvalid)\n .optional(),\n tiktokHandle: z\n .string()\n .regex(/^$|^@?[a-zA-Z0-9][a-zA-Z0-9._]{1,23}$/, ATHLETE_PROFILE_ERRORS.TiktokInvalid)\n .optional(),\n highlightImage: z\n .union([\n z\n .instanceof(File)\n .refine(\n file => file.size <= 5 * 1024 * 1024, // 5MB\n ATHLETE_PROFILE_ERRORS.HighlightImageSize\n )\n .refine(\n file => ['image/png', 'image/jpeg', 'image/jpg'].includes(file.type),\n ATHLETE_PROFILE_ERRORS.HighlightImageTypes\n ),\n z.string(),\n z.null(),\n ])\n .optional(),\n});\n\n/**\n * Type inferred from basicProfileSchema for basic profile form data\n */\nexport type BasicProfileFormData = z.infer<typeof basicProfileSchema>;\n\n/**\n * Type inferred from fanProfileSchema for fan profile form data\n */\nexport type FanProfileFormData = z.infer<typeof fanProfileSchema>;\n\n/**\n * Type inferred from athleteProfileSchema for athlete profile form data\n */\nexport type AthleteProfileFormData = z.infer<typeof athleteProfileSchema>;\n"]}
|
package/package.json
CHANGED