Fields are defined with properties that control their appearance and behavior:
Copy
interface FieldDefinition { /** Display label for the field */ label?: string; /** Field type (string, number, boolean, etc.) */ type?: string; /** Whether the field is required */ required?: boolean; /** Options for select fields */ options?: string[]; /** Whether the field is hidden */ hidden?: boolean | ((data: Record<string, unknown>) => boolean); /** Whether the field is read-only */ readOnly?: boolean | ((data: Record<string, unknown>) => boolean); /** Description text for the field */ description?: string; /** Placeholder text for input fields */ placeholder?: string; /** Validation rules for the field */ validation?: { min?: number; max?: number; pattern?: string; message?: string; };}
The Schema module provides utilities for converting between different schema formats:
Copy
import { convertLegacySchema } from '@repo/view/schema';// Convert a legacy array-based schema to the new record-based formatconst modernSchema = convertLegacySchema(legacySchema);
The Schema module integrates with the CRUD package to ensure compatibility:
Copy
import { createCrudSchemaFromViewSchema } from '@repo/view/schema';// Create a CRUD schema from a view schemaconst crudSchema = createCrudSchemaFromViewSchema(viewSchema);