From 56dc6e3642e61c5817d67b743f3fd0fdd580c828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= Date: Tue, 3 Sep 2024 15:25:06 +0200 Subject: [PATCH] zod: Add UInt --- package.json | 2 +- src/zod.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dfd9487..72f4444 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libshv-js", - "version": "3.2.0", + "version": "3.2.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 f637964..1260430 100644 --- a/src/zod.ts +++ b/src/zod.ts @@ -1,9 +1,10 @@ import {z, type ZodType} from 'zod'; -import {type IMap, Int, isIMap, isShvMap, type RpcValue, type ShvMap} from './rpcvalue'; +import {type IMap, Int, isIMap, isShvMap, type RpcValue, type ShvMap, UInt} from './rpcvalue'; export const map = >>(schema: T) => z.custom}>>((data: RpcValue) => isShvMap(data) && z.object(schema).safeParse(data).success); export const recmap = >(schema: T) => z.custom>>>((data: RpcValue) => isShvMap(data) && z.record(z.string(), schema).safeParse(data).success); export const imap = >>(schema: T) => z.custom}>>((data: RpcValue) => isIMap(data) && z.object(schema).safeParse(data).success); export const int = () => z.custom((data: RpcValue) => data instanceof Int); +export const uint = () => z.custom((data: RpcValue) => data instanceof UInt); export * from 'zod';