This commit is contained in:
手瓜一十雪
2025-04-17 09:52:03 +08:00
parent abe6e46750
commit a2d11a7d7d
88 changed files with 87 additions and 88 deletions

14
src/common/coerce.ts Normal file
View File

@@ -0,0 +1,14 @@
import { z } from "zod";
const boolean = () => z.preprocess(
val => typeof val === 'string' && (val.toLowerCase() === 'false' || val === '0') ? false : Boolean(val),
z.boolean()
);
const number = () => z.preprocess(
val => typeof val !== 'number' ? Number(val) : val,
z.number()
);
const string = () => z.preprocess(
val => typeof val !== 'string' ? String(val) : val,
z.string()
);
export const actionType = { boolean, number, string };