manicanldes-backend/src/inventory/material-adjustment.schemas.ts

25 lines
770 B
TypeScript

import { z } from 'zod';
import { pageSchema } from '../identity/identity.schemas';
const signedQuantity = z
.string()
.regex(/^-?(?:0|[1-9]\d{0,8})\.\d{3}$/)
.refine((value) => value !== '0.000' && value !== '-0.000');
export const materialAdjustmentSchema = z
.object({
materialId: z.uuid(),
warehouseId: z.uuid(),
delta: signedQuantity,
reason: z.string().trim().min(3).max(200),
idempotencyKey: z.uuid(),
})
.strict();
export const materialAdjustmentQuery = pageSchema
.extend({
materialId: z.uuid().optional(),
warehouseId: z.uuid().optional(),
})
.strict();
export type MaterialAdjustmentInput = z.infer<typeof materialAdjustmentSchema>;
export type MaterialAdjustmentQuery = z.infer<typeof materialAdjustmentQuery>;