-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from UTDNebula/JUP-49-improve-contacts
JUP-49: improve club contacts
- Loading branch information
Showing
5 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { z } from 'zod'; | ||
|
||
const emailSchema = z.object({ | ||
platform: z.literal('email'), | ||
clubId: z.string().optional(), | ||
url: z.string().email('Must be a valid email'), | ||
}); | ||
const discordSchema = z.object({ | ||
platform: z.literal('discord'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
|
||
const youtubeSchema = z.object({ | ||
platform: z.literal('youtube'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
|
||
const twitchSchema = z.object({ | ||
platform: z.literal('twitch'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
|
||
const facebookSchema = z.object({ | ||
platform: z.literal('facebook'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
|
||
const twitterSchema = z.object({ | ||
platform: z.literal('twitter'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
const instagramSchema = z.object({ | ||
platform: z.literal('instagram'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
|
||
const websiteSchema = z.object({ | ||
platform: z.literal('website'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('Valid url required'), | ||
}); | ||
|
||
const otherSchema = z.object({ | ||
platform: z.literal('other'), | ||
clubId: z.string().optional(), | ||
url: z.string().url('must be a valid url'), | ||
}); | ||
|
||
export const contactSchema = z.discriminatedUnion('platform', [ | ||
emailSchema, | ||
discordSchema, | ||
youtubeSchema, | ||
twitchSchema, | ||
facebookSchema, | ||
twitterSchema, | ||
instagramSchema, | ||
websiteSchema, | ||
otherSchema, | ||
]); | ||
export type contact = z.infer<typeof contactSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters