This commit is contained in:
2026-03-22 13:55:23 +08:00
parent c3f196ded4
commit 69099986e0
616 changed files with 38942 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
import { z } from 'zod'
export const accountValidator = z.object({
name: z
.string({
error: 'Required.',
})
.min(2, {
error: 'Name must be at least 2 characters.',
})
.max(30, {
error: 'Name must not be longer than 30 characters.',
}),
dob: z
.iso
.datetime()
.optional()
.refine(date => date !== undefined, 'Please select a valid date.'),
language: z
.string()
.min(1, 'Please select a language.'),
})
export type AccountValidator = z.infer<typeof accountValidator>

View File

@@ -0,0 +1,14 @@
import { z } from 'zod'
export const appearanceValidator = z.object({
theme: z
.enum(['light', 'dark'], {
error: 'Please select a theme.',
}),
font: z
.enum(['inter', 'manrope', 'system'], {
error: 'Please select a font.',
}),
})
export type AppearanceValidator = z.infer<typeof appearanceValidator>

View File

@@ -0,0 +1,11 @@
import { z } from 'zod'
export const displayValidator = z.object({
items: z
.array(z.string())
.refine(value => value.some(item => item), {
error: 'You have to select at least one item.',
}),
})
export type DisplayValidator = z.infer<typeof displayValidator>

View File

@@ -0,0 +1,28 @@
import { z } from 'zod'
export const notificationsValidator = z.object({
type: z
.enum(['all', 'mentions', 'none'], {
error: 'You need to select a notification type.',
}),
mobile: z
.boolean()
.default(false)
.optional(),
communication_emails: z
.boolean()
.default(false)
.optional(),
social_emails: z
.boolean()
.default(false)
.optional(),
marketing_emails: z
.boolean()
.default(false)
.optional(),
security_emails: z
.boolean(),
})
export type NotificationsValidator = z.infer<typeof notificationsValidator>

View File

@@ -0,0 +1,29 @@
import { z } from 'zod'
export const profileValidator = z.object({
username: z
.string()
.min(2, {
error: 'Username must be at least 2 characters.',
})
.max(30, {
error: 'Username must not be longer than 30 characters.',
}),
email: z
.email({
error: 'Please select an email to display.',
}),
bio: z
.string()
.max(160, { error: 'Bio must not be longer than 160 characters.' })
.min(4, { error: 'Bio must be at least 2 characters.' }),
urls: z
.array(
z.object({
value: z.url({ error: 'Please enter a valid URL.' }),
}),
)
.optional(),
})
export type ProfileValidator = z.infer<typeof profileValidator>