Skip to content

Commit e634905

Browse files
committed
feat(event): upgrade zod to v4
1 parent 8594333 commit e634905

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

src/app/components/preference/form/PreferenceFormSize.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const { handleSubmit } = useForm({
103103
initialValues: { items: initialSelectedItems },
104104
validationSchema: toTypedSchema(
105105
z.object({
106-
items: z.array(z.nativeEnum(EventSize)),
106+
items: z.array(z.enum(EventSize)),
107107
}),
108108
),
109109
})

src/server/api/model/event/ical.post.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ const icalPostBodySchema = z.object({
1111
})
1212
.optional(),
1313
event: z.object({
14-
id: z.string(),
14+
id: z.uuidv4(),
1515
description: z.string().optional().nullable(),
16-
end: z.string().optional().nullable(),
16+
end: z.iso.datetime({ offset: true }).optional().nullable(),
1717
location: z.string().optional().nullable(),
1818
name: z.string(),
19-
start: z.string(),
19+
start: z.iso.datetime({ offset: true }),
2020
accountByCreatedBy: z.object({
2121
id: z.string(),
2222
username: z.string(),
2323
}),
2424
slug: z.string(),
25-
visibility: z.nativeEnum(EventVisibility),
25+
visibility: z.enum(EventVisibility),
2626
}),
2727
invitation: z
2828
.object({
29-
id: z.string(),
29+
id: z.uuidv4(),
3030
})
3131
.optional(),
3232
})

src/server/api/model/event/ingest/image.post.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const eventIngestImagePostBodySchema = z.object({
77
})
88
const eventSchema = z.object({
99
description: z.string(),
10-
end: z.string().optional(),
10+
end: z.string().optional(), // TODO: z.iso.datetime({ offset: true }) when OpenAI supports it
1111
is_event: z.boolean(),
1212
location: z.string().optional(),
1313
name: z.string().optional(),
14-
start: z.string().optional(),
15-
url: z.string().optional(),
14+
start: z.string().optional(), // TODO: z.iso.datetime({ offset: true }) when OpenAI supports it
15+
url: z.string().optional(), // TODO: z.url() when OpenAI supports it
1616
})
1717
const prompt = `You are a data extraction specialist responsible for identifying and accurately cataloging event information.
1818
Only accept images. Only if the image is an event poster containing event information, extract that information into JSON. In all other cases, set \`is_event\` to \`false\`.

src/server/api/model/event/ingest/url.post.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const eventIngestUrlPostBodySchema = z.object({
77
})
88
const eventSchema = z.object({
99
description: z.string(),
10-
end: z.string().optional(),
10+
end: z.string().optional(), // TODO: z.iso.datetime({ offset: true }) when OpenAI supports it
1111
is_event: z.boolean(),
1212
location: z.string().optional(),
1313
name: z.string().optional(),
14-
start: z.string().optional(),
14+
start: z.string().optional(), // TODO: z.iso.datetime({ offset: true }) when OpenAI supports it
1515
})
1616
const prompt = `You are a data extraction specialist responsible for identifying and cataloging event information.
1717
Only accept html. Only if the html contains event information, extract that information into JSON. For dates, use ISO 8601 and the current year (${new Date().getFullYear()}) if no year is given. In all other cases, set all fields to an empty string and \`is_event\` to \`false\`.`

src/server/api/test/email.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Locale } from '~~/server/utils/i18n'
77
import { getQuerySafe } from '~~/server/utils/validation'
88

99
const emailGetQuerySchema = z.object({
10-
locale: z.nativeEnum(Locale).default(Locale.EN),
10+
locale: z.enum(Locale).default(Locale.EN),
1111
name: EMAIL_NAMES.optional(),
1212
})
1313

src/server/utils/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export enum Locale {
66
DE = 'de',
77
EN = 'en',
88
}
9-
export const LocaleSchema = z.nativeEnum(Locale)
9+
export const LocaleSchema = z.enum(Locale)

src/shared/utils/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { z } from 'zod'
22

33
export const schemaFormContact = z.object({
44
consent: z.boolean().refine((value) => value === true),
5-
emailAddress: z.string().email().max(1000),
5+
emailAddress: z.email().max(1000),
66
name: z.string().max(100),
77
message: z.string().max(10000),
88
})
99
export const schemaFormEarlyBird = z.object({
1010
agreement: z.boolean().refine((value) => value === true),
11-
emailAddress: z.string().email().max(1000),
11+
emailAddress: z.email().max(1000),
1212
name: z.string().max(100),
1313
})

0 commit comments

Comments
 (0)