18 lines
520 B
TypeScript
18 lines
520 B
TypeScript
import { z } from "zod";
|
|
|
|
export const CharacterSchema = z
|
|
.object({
|
|
id: z.string().min(1).max(64),
|
|
slug: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
displayName: z.string().trim().min(1).max(80),
|
|
avatarUrl: z.url().refine((url) => url.startsWith("https://"), {
|
|
message: "avatarUrl must use HTTPS",
|
|
}),
|
|
})
|
|
.readonly();
|
|
|
|
export type CharacterInput = z.input<typeof CharacterSchema>;
|
|
export type CharacterData = z.output<typeof CharacterSchema>;
|
|
|
|
export type Character = CharacterData;
|