fix: align frontend zod schemas with backend validation rules
Tightened frontend zod schemas where backend required fields the frontend marked optional, and matched enum/format constraints. Schemas: - vehicle-document: document_type required - parts: shop_type, category, unit_type, department, sku required - inspections: customer, vehicle, department, inspection_category, employee, order_number, date, time required - appointments: service_writer required, cross-field to_time > from_time - vendor-credits: vendor + vendor_credit_date required - job-cards: documents[].document_type_id required - expense-items: category, unit_type, department, sku required - inventory-adjustments: reference_number, date required - tasks: task_type, task_section required - shop-timings: in_time, out_time enforce HH:MM:SS regex - vendor-credit: subject + vendor + vendor_credit_date required Settings: - shop-type: shop_type + note required - insurance-types: description field added, required - make-and-models: shop_type required, year 1900..2100 - departments: assignment_type required enum (AssignmentType) - company: website URL validation, latitude/longitude range, first_day_of_work enum, string max lengths - configurations: 4 fields enum-typed (was raw strings) Inline forms: - job-card service/part/expense-item: relations required (part/service/expense_item/department) - job-card recommendation: max 255 - vehicles/inline-forms/shop-type: shop_type + note required - vehicles/inline-forms/body-type: shop_type_id pulled from parent form context, guard on submit - vehicles/inline-forms/color: code field added, required - services/inline-forms/department: assignment_type required enum - tasks/task-section: arrangement required integer - invoices/invoice-edit: status + discount enum-typed Auth: - login: password min 6 (was 8; backend allows 6) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
349a458c3c
commit
cc7dc1bd17
@@ -22,13 +22,13 @@ import { z } from "zod"
|
||||
// ── Schema for edit form (simplified, edit only) ──
|
||||
|
||||
const invoiceEditFormSchema = z.object({
|
||||
subject: z.string().min(1, "Subject is required"),
|
||||
subject: z.string().min(1, "Subject is required").max(255, "Subject cannot exceed 255 characters"),
|
||||
due_date: z.string().optional(),
|
||||
invoice_title: z.string().optional(),
|
||||
invoice_title: z.string().max(255, "Invoice title cannot exceed 255 characters").optional(),
|
||||
notes: z.string().optional(),
|
||||
terms_and_conditions: z.string().optional(),
|
||||
status: z.string().optional(),
|
||||
discount: z.string().optional(),
|
||||
status: z.enum(InvoiceStatus).optional(),
|
||||
discount: z.enum(InvoiceDiscount).optional(),
|
||||
})
|
||||
|
||||
type InvoiceEditFormValues = z.infer<typeof invoiceEditFormSchema>
|
||||
@@ -53,7 +53,7 @@ const DEFAULT_VALUES: InvoiceEditFormValues = {
|
||||
invoice_title: "",
|
||||
notes: "",
|
||||
terms_and_conditions: "",
|
||||
status: "",
|
||||
status: undefined,
|
||||
discount: "no",
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ function mapToFormValues(data: unknown): InvoiceEditFormValues {
|
||||
invoice_title: d.invoice_title || "",
|
||||
notes: d.notes || "",
|
||||
terms_and_conditions: d.terms_and_conditions || "",
|
||||
status: d.status || "",
|
||||
status: d.status || undefined,
|
||||
discount: d.discount || "no",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user