libshv-js 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/zod.ts +7 -6
package/package.json
CHANGED
package/src/zod.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {z, type ZodType} from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import {Int, shvMapType, UInt} from './rpcvalue';
|
|
3
3
|
|
|
4
|
-
export const map = <T extends Record<string, ZodType<any, any, any>>>(schema: T) => z.
|
|
5
|
-
export const recmap = <T extends ZodType<any, any, any>>(schema: T) => z.
|
|
6
|
-
export const imap = <T extends Record<string, ZodType<any, any, any>>>(schema: T) => z.
|
|
7
|
-
|
|
8
|
-
export const
|
|
4
|
+
export const map = <T extends Record<string, ZodType<any, any, any>>>(schema: T) => z.object(schema).and(z.object({[shvMapType]: z.literal('map')}));
|
|
5
|
+
export const recmap = <T extends ZodType<any, any, any>>(schema: T) => z.record(z.string(), schema).and(z.object({[shvMapType]: z.literal('map')}));
|
|
6
|
+
export const imap = <T extends Record<string, ZodType<any, any, any>>>(schema: T) => z.object(schema).and(z.object({[shvMapType]: z.literal('imap')}));
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -- Zod needs the default argument, otherwise it'll infer as Int<unknown>
|
|
8
|
+
export const int = () => z.instanceof(Int<number>);
|
|
9
|
+
export const uint = () => z.instanceof(UInt);
|
|
9
10
|
|
|
10
11
|
export * from 'zod';
|