update: change the validation rule in the question backend endpoint to validate the number of characters in the question form

This commit is contained in:
falendikategar 2024-10-24 10:56:20 +07:00
parent ebbadf5e02
commit 55abddddd3

View File

@ -17,19 +17,19 @@ import { options } from "../../drizzle/schema/options";
// Schema for creating and updating options
export const optionFormSchema = z.object({
text: z.string().min(1).max(255),
score: z.number().min(0),
score: z.number().min(0).max(999),
});
// Schema for creating and updating questions
export const questionFormSchema = z.object({
subAspectId: z.string().min(1).max(255),
question: z.string().min(1).max(255),
question: z.string().min(1).max(510),
needFile: z.boolean().default(false),
options: z.array(optionFormSchema).optional(), // Allow options to be included
});
export const questionUpdateSchema = questionFormSchema.extend({
question: z.string().min(1).max(255).or(z.literal("")),
question: z.string().min(1).max(510).or(z.literal("")),
subAspectId: z.string().min(1).max(255).or(z.literal("")),
needFile: z.boolean().default(false).or(z.boolean()),
});