Story 2 van PBI "Alle dialogen conform docs/patterns/dialog.md". - lib/schemas/product.ts — gedeeld zod-schema (Dialog API) - actions/products.ts — createProductAction/updateProductAction returnen nu code+fieldErrors voor 422-validatie en code: 403 voor demo/auth - ProductDialog adopt useDirtyCloseGuard, useDialogSubmitShortcut, entityDialog* layout-classes; 422-fieldErrors mappen naar form.setError - docs/specs/dialogs/product.md — entity-profile Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
18 lines
677 B
TypeScript
18 lines
677 B
TypeScript
import { z } from 'zod'
|
|
|
|
export const productSchema = z.object({
|
|
name: z.string().trim().min(1, 'Naam is verplicht').max(200, 'Maximaal 200 tekens'),
|
|
code: z.string().trim().max(20, 'Maximaal 20 tekens').optional(),
|
|
description: z.string().max(4000, 'Maximaal 4000 tekens').optional(),
|
|
repo_url: z
|
|
.string()
|
|
.url('Voer een geldige URL in (inclusief https://)')
|
|
.regex(/^https:\/\/github\.com\//, 'Alleen GitHub-URLs worden ondersteund')
|
|
.optional()
|
|
.nullable()
|
|
.or(z.literal('')),
|
|
definition_of_done: z.string().max(4000, 'Maximaal 4000 tekens').optional(),
|
|
auto_pr: z.boolean(),
|
|
})
|
|
|
|
export type ProductInput = z.infer<typeof productSchema>
|