UNPKG

@tmlmobilidade/types

Version:

This package provides shared Zod validation schemas and their corresponding TypeScript types for use across projects. All types are automatically inferred from the schemas to ensure full type safety and reduce maintenance overhead.

31 lines (30 loc) 922 B
/* * */ import { DocumentSchema } from './document.js'; import { z } from 'zod'; /* * */ // // Define constants for enum values for better maintainability const SCOPE_VALUES = [ 'stop', 'lines', ]; const STATUS_VALUES = [ 'pending', 'accepted', 'declined', ]; // // Define schemas using constants export const scopeSchema = z.enum(SCOPE_VALUES); export const statusSchema = z.enum(STATUS_VALUES).default('pending'); export const ProposedChangeSchema = DocumentSchema.extend({ field_path: z.string(), field_value: z.any(), scope: scopeSchema, status: statusSchema, target_id: z.string(), user_id: z.string(), }).strict(); export const CreateProposedChangeSchema = ProposedChangeSchema .omit({ _id: true, created_at: true, updated_at: true }); export const UpdateProposedChangeSchema = ProposedChangeSchema .omit({ _id: true, created_at: true, updated_at: true }) .partial();