mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-12 07:50:25 +00:00
fix
This commit is contained in:
14
src/common/coerce.ts
Normal file
14
src/common/coerce.ts
Normal 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 };
|
||||
Reference in New Issue
Block a user