From 91837770c8e51aaf0b5b1bb2a1e78729873109d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= Date: Tue, 22 Oct 2024 09:24:01 +0200 Subject: [PATCH] zod: Add support for double/decimal/blob --- package.json | 2 +- src/zod.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4715d56..3619f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libshv-js", - "version": "3.4.0", + "version": "3.4.1", "description": "Typescript implementation of libshv", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", diff --git a/src/zod.ts b/src/zod.ts index 621d547..93af0d5 100644 --- a/src/zod.ts +++ b/src/zod.ts @@ -8,6 +8,9 @@ export const metamap = export const int = () => z.number(); // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -- Zod needs the default argument, otherwise it'll infer as UInt export const uint = () => z.instanceof(UInt); +export const double = () => z.instanceof(Double); +export const decimal = () => z.instanceof(Decimal); +export const blob = () => z.instanceof(ArrayBuffer); const withMetaInstanceParser = z.instanceof(RpcValueWithMetaData); export const rpcvalue = () => z.union([ @@ -15,9 +18,9 @@ export const rpcvalue = () => z.union([ z.boolean(), z.number(), uint(), - z.instanceof(Double), - z.instanceof(Decimal), - z.instanceof(ArrayBuffer), + double(), + decimal(), + blob(), z.string(), z.date(), z.array(z.any()),