manicanldes-backend/src/costing/costing.schemas.ts

17 lines
654 B
TypeScript

import { z } from 'zod';
import { CURRENCIES } from '../common/currency';
import { pageSchema } from '../identity/identity.schemas';
const currency = z.enum(CURRENCIES);
export const costRateSchema = z
.object({
currency,
unitCost: z.string().regex(/^(?!0\.0000$)(?:0|[1-9]\d{0,7})\.\d{4}$/),
})
.strict();
export const costQuerySchema = z.object({ currency }).strict();
export const costHistoryQuerySchema = pageSchema.extend({ currency }).strict();
export type CostRateInput = z.infer<typeof costRateSchema>;
export type CostQuery = z.infer<typeof costQuerySchema>;
export type CostHistoryQuery = z.infer<typeof costHistoryQuerySchema>;