Complete all for Items

This commit is contained in:
2026-07-17 14:27:51 +05:30
parent f72b24fcaa
commit 62a5d857de
103 changed files with 2540 additions and 3259 deletions
+7 -10
View File
@@ -1,19 +1,16 @@
import { z } from "zod"
// Treats null/undefined as missing so validation surfaces one clear
// "required" message instead of a generic type error.
// Plain z.string(), not z.preprocess(): preprocess widens the schema's INPUT type to
// `unknown`, so zodResolver produced a Resolver<{email: unknown, …}> that could not be
// assigned to useForm<LoginValues> — the long-standing type error on the login page.
// Form fields always yield strings (RHF defaults them to ""), so the null/undefined
// coercion it was guarding against cannot occur here.
function requiredString(message: string) {
return z.preprocess(
(val) => (val === null || val === undefined ? "" : val),
z.string().min(1, message)
)
return z.string().min(1, message)
}
// Email validation schema
export const emailSchema = z.preprocess(
(val) => (val === null || val === undefined ? "" : val),
z.string().min(1, "Email is required").email("Enter a valid email")
)
export const emailSchema = z.string().min(1, "Email is required").email("Enter a valid email")
// Login schema (email + password) for reuse across the app
export const loginSchema = z.object({