Enhance tags
This commit is contained in:
@ -1,11 +1,20 @@
|
||||
import { z } from "zod/v4"
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const tagSchema = z.object({
|
||||
name: z.string().min(3, "Name is required. Min 3 characters."),
|
||||
slug: z.string().min(3, "Slug is required. Min 3 characters.").regex(/^[a-z]+$/, "Only lowercase letters are allowed (no numbers, spaces, or uppercase)"),
|
||||
description: z.string().optional(),
|
||||
categoryIds: z.array(z.string()).optional(),
|
||||
parentId: z.string().nullable().optional(),
|
||||
|
||||
aliases: z
|
||||
.array(z.string().trim().min(1))
|
||||
.default([])
|
||||
.transform((arr) => {
|
||||
const normalized = arr.map((s) => s.trim().toLowerCase()).filter(Boolean);
|
||||
return Array.from(new Set(normalized));
|
||||
}),
|
||||
})
|
||||
|
||||
export type tagSchema = z.infer<typeof tagSchema>
|
||||
export type TagFormInput = z.input<typeof tagSchema>;
|
||||
export type TagFormOutput = z.output<typeof tagSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user