corrected schemas
This commit is contained in:
@@ -2,14 +2,19 @@ import { z } from "zod";
|
|||||||
import { LABELS } from "~/lib/data/task-labels";
|
import { LABELS } from "~/lib/data/task-labels";
|
||||||
import { VARIANTS } from "~/lib/data/list-variants";
|
import { VARIANTS } from "~/lib/data/list-variants";
|
||||||
|
|
||||||
export const listNameSchema = z.string().max(128);
|
export const listNameSchema = z
|
||||||
|
.string()
|
||||||
|
.min(1, "title cannot be empty")
|
||||||
|
.max(128, "title cannot be more than 128 characters");
|
||||||
|
|
||||||
export const listCreationFormSchema = z.object({
|
export const listCreationFormSchema = z.object({
|
||||||
name: listNameSchema, // Text
|
name: listNameSchema, // Text
|
||||||
variant: z.union([z.enum(VARIANTS).optional(), z.literal("")]), // Radio group
|
variant: z.enum(VARIANTS, {
|
||||||
|
message: "you must select a variant",
|
||||||
|
}), // Radio group
|
||||||
labels: z.array(z.enum(LABELS)), // Checkbox group
|
labels: z.array(z.enum(LABELS)), // Checkbox group
|
||||||
id: z.boolean(), // Checkbox
|
id: z.boolean(), // Checkbox
|
||||||
idPrefix: z.string().max(8), // Text
|
idPrefix: z.string().max(8).optional(), // Text
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ListCreation = z.infer<typeof listCreationFormSchema>;
|
export type ListCreationSchema = z.infer<typeof listCreationFormSchema>;
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ import { z } from "zod";
|
|||||||
|
|
||||||
export const taskCreationFormSchema = z.object({});
|
export const taskCreationFormSchema = z.object({});
|
||||||
|
|
||||||
export type TaskCreation = z.infer<typeof taskCreationFormSchema>;
|
export type TaskCreationSchema = z.infer<typeof taskCreationFormSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user