@xylabs/zod 5.0.94 → 5.0.96

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/README.md CHANGED
@@ -1,67 +1,59 @@
1
1
  # @xylabs/zod
2
2
 
3
- [![logo][]](https://xylabs.com)
3
+ [![npm][npm-badge]][npm-link]
4
+ [![license][license-badge]][license-link]
4
5
 
5
- [![main-build][]][main-build-link]
6
- [![npm-badge][]][npm-link]
7
- [![npm-downloads-badge][]][npm-link]
8
- [![jsdelivr-badge][]][jsdelivr-link]
9
- [![npm-license-badge][]](LICENSE)
10
- [![codacy-badge][]][codacy-link]
11
- [![codeclimate-badge][]][codeclimate-link]
12
- [![snyk-badge][]][snyk-link]
13
- [![socket-badge][]][socket-link]
6
+ > Base functionality used throughout XY Labs TypeScript/JavaScript libraries
14
7
 
8
+ ## Install
15
9
 
16
- Base functionality used throughout XY Labs TypeScript/JavaScript libraries
10
+ Using npm:
17
11
 
12
+ ```sh
13
+ npm install {{name}}
14
+ ```
18
15
 
16
+ Using yarn:
19
17
 
20
- ## Reference
18
+ ```sh
19
+ yarn add {{name}}
20
+ ```
21
21
 
22
- **@xylabs/zod**
22
+ Using pnpm:
23
23
 
24
- ***
24
+ ```sh
25
+ pnpm add {{name}}
26
+ ```
27
+
28
+ Using bun:
29
+
30
+ ```sh
31
+ bun add {{name}}
32
+ ```
25
33
 
26
- ## Interfaces
27
34
 
28
- | Interface | Description |
29
- | ------ | ------ |
30
- | [ZodFactoryConfigObject](#interfaces/ZodFactoryConfigObject) | Configuration object for zod factory functions, providing a name for error messages. |
35
+ ## License
36
+
37
+ See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
31
38
 
32
- ## Type Aliases
39
+ ## Reference
33
40
 
34
- | Type Alias | Description |
35
- | ------ | ------ |
36
- | [ZodFactoryConfig](#type-aliases/ZodFactoryConfig) | Configuration for zod factory assertion behavior, either an AssertConfig or a named config object. |
37
- | [AllZodFactories](#type-aliases/AllZodFactories) | - |
41
+ ### packages
38
42
 
39
- ## Functions
43
+ ### zod
40
44
 
41
- | Function | Description |
42
- | ------ | ------ |
43
- | [zodAllFactory](#functions/zodAllFactory) | Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schema. |
44
- | [zodAsAsyncFactory](#functions/zodAsAsyncFactory) | Creates an async function that validates a value against a zod schema and returns it with a narrowed type. Uses `safeParseAsync` for schemas with async refinements. When called without an assert config, returns undefined on failure. |
45
- | [zodAsFactory](#functions/zodAsFactory) | Creates a function that validates a value against a zod schema and returns it with a narrowed type. When called without an assert config, returns undefined on failure. When called with an assert config, throws on failure. |
46
- | [zodIsFactory](#functions/zodIsFactory) | Creates a type guard function that checks if a value matches a zod schema. |
47
- | [zodToAsyncFactory](#functions/zodToAsyncFactory) | Creates an async function that converts a value to the zod schema type, delegating to `zodAsAsyncFactory` internally. Provides overloads for optional assertion: without assert config resolves to undefined on failure, with assert config throws on failure. |
48
- | [zodToFactory](#functions/zodToFactory) | Creates a function that converts a value to the zod schema type, delegating to `zodAsFactory` internally. Provides overloads for optional assertion: without assert config returns undefined on failure, with assert config throws on failure. |
45
+ ### .temp-typedoc
49
46
 
50
- ### functions
47
+ ### functions
51
48
 
52
- ### <a id="zodAllFactory"></a>zodAllFactory
49
+ ### <a id="zodAllFactory"></a>zodAllFactory
53
50
 
54
51
  [**@xylabs/zod**](#../README)
55
52
 
56
53
  ***
57
54
 
58
55
  ```ts
59
- function zodAllFactory<T, TName>(zod: ZodType<T>, name: TName): {
60
- [key: string]: {
61
- <T> (value: T): T & T | undefined;
62
- <T> (value: T, assert: ZodFactoryConfig): T & T;
63
- };
64
- };
56
+ function zodAllFactory<T, TName>(zod, name): object;
65
57
  ```
66
58
 
67
59
  **`Alpha`**
@@ -70,41 +62,44 @@ Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schem
70
62
 
71
63
  ## Type Parameters
72
64
 
73
- | Type Parameter |
74
- | ------ |
75
- | `T` |
76
- | `TName` *extends* `string` |
65
+ ### T
66
+
67
+ `T`
68
+
69
+ ### TName
70
+
71
+ `TName` *extends* `string`
77
72
 
78
73
  ## Parameters
79
74
 
80
- | Parameter | Type | Description |
81
- | ------ | ------ | ------ |
82
- | `zod` | `ZodType`\<`T`\> | The zod schema to validate against |
83
- | `name` | `TName` | The name used to suffix the generated function names (e.g. 'Address' produces `isAddress`, `asAddress`, `toAddress`) |
75
+ ### zod
76
+
77
+ `ZodType`\<`T`\>
78
+
79
+ The zod schema to validate against
80
+
81
+ ### name
82
+
83
+ `TName`
84
+
85
+ The name used to suffix the generated function names (e.g. 'Address' produces `isAddress`, `asAddress`, `toAddress`)
84
86
 
85
87
  ## Returns
86
88
 
87
- ```ts
88
- {
89
- [key: string]: {
90
- <T> (value: T): T & T | undefined;
91
- <T> (value: T, assert: ZodFactoryConfig): T & T;
92
- };
93
- }
94
- ```
89
+ `object`
95
90
 
96
91
  An object containing `is<Name>`, `as<Name>`, and `to<Name>` functions
97
92
 
98
- ### <a id="zodAsAsyncFactory"></a>zodAsAsyncFactory
93
+ ### <a id="zodAsAsyncFactory"></a>zodAsAsyncFactory
99
94
 
100
95
  [**@xylabs/zod**](#../README)
101
96
 
102
97
  ***
103
98
 
104
99
  ```ts
105
- function zodAsAsyncFactory<TZod>(zod: ZodType<TZod>, name: string): {
106
- <T> (value: T): Promise<T & TZod | undefined>;
107
- <T> (value: T, assert: ZodFactoryConfig): Promise<T & TZod>;
100
+ function zodAsAsyncFactory<TZod>(zod, name): {
101
+ <T> (value): Promise<T & TZod | undefined>;
102
+ <T> (value, assert): Promise<T & TZod>;
108
103
  };
109
104
  ```
110
105
 
@@ -113,72 +108,43 @@ Uses `safeParseAsync` for schemas with async refinements. When called without an
113
108
 
114
109
  ## Type Parameters
115
110
 
116
- | Type Parameter |
117
- | ------ |
118
- | `TZod` |
111
+ ### TZod
119
112
 
120
- ## Parameters
121
-
122
- | Parameter | Type | Description |
123
- | ------ | ------ | ------ |
124
- | `zod` | `ZodType`\<`TZod`\> | The zod schema to validate against |
125
- | `name` | `string` | A name used in error messages for identification |
126
-
127
- ## Returns
113
+ `TZod`
128
114
 
129
- An async function that validates and narrows the type of a value
130
-
131
- ```ts
132
- <T>(value: T): Promise<T & TZod | undefined>;
133
- ```
134
-
135
- ### Type Parameters
136
-
137
- | Type Parameter |
138
- | ------ |
139
- | `T` |
140
-
141
- ### Parameters
142
-
143
- | Parameter | Type |
144
- | ------ | ------ |
145
- | `value` | `T` |
115
+ ## Parameters
146
116
 
147
- ### Returns
117
+ ### zod
148
118
 
149
- `Promise`\<`T` & `TZod` \| `undefined`\>
119
+ `ZodType`\<`TZod`\>
150
120
 
151
- ```ts
152
- <T>(value: T, assert: ZodFactoryConfig): Promise<T & TZod>;
153
- ```
121
+ The zod schema to validate against
154
122
 
155
- ### Type Parameters
123
+ ### name
156
124
 
157
- | Type Parameter |
158
- | ------ |
159
- | `T` |
125
+ `string`
160
126
 
161
- ### Parameters
127
+ A name used in error messages for identification
162
128
 
163
- | Parameter | Type |
164
- | ------ | ------ |
165
- | `value` | `T` |
166
- | `assert` | [`ZodFactoryConfig`](#../type-aliases/ZodFactoryConfig) |
129
+ ## Returns
167
130
 
168
- ### Returns
131
+ An async function that validates and narrows the type of a value
169
132
 
170
- `Promise`\<`T` & `TZod`\>
133
+ \{
134
+ \<`T`\> (`value`): `Promise`\<`T` & `TZod` \| `undefined`\>;
135
+ \<`T`\> (`value`, `assert`): `Promise`\<`T` & `TZod`\>;
136
+ \}
171
137
 
172
- ### <a id="zodAsFactory"></a>zodAsFactory
138
+ ### <a id="zodAsFactory"></a>zodAsFactory
173
139
 
174
140
  [**@xylabs/zod**](#../README)
175
141
 
176
142
  ***
177
143
 
178
144
  ```ts
179
- function zodAsFactory<TZod>(zod: ZodType<TZod>, name: string): {
180
- <T> (value: T): T & TZod | undefined;
181
- <T> (value: T, assert: ZodFactoryConfig): T & TZod;
145
+ function zodAsFactory<TZod>(zod, name): {
146
+ <T> (value): T & TZod | undefined;
147
+ <T> (value, assert): T & TZod;
182
148
  };
183
149
  ```
184
150
 
@@ -187,120 +153,75 @@ When called without an assert config, returns undefined on failure. When called
187
153
 
188
154
  ## Type Parameters
189
155
 
190
- | Type Parameter |
191
- | ------ |
192
- | `TZod` |
193
-
194
- ## Parameters
195
-
196
- | Parameter | Type | Description |
197
- | ------ | ------ | ------ |
198
- | `zod` | `ZodType`\<`TZod`\> | The zod schema to validate against |
199
- | `name` | `string` | A name used in error messages for identification |
200
-
201
- ## Returns
202
-
203
- A function that validates and narrows the type of a value
204
-
205
- ```ts
206
- <T>(value: T): T & TZod | undefined;
207
- ```
156
+ ### TZod
208
157
 
209
- ### Type Parameters
158
+ `TZod`
210
159
 
211
- | Type Parameter |
212
- | ------ |
213
- | `T` |
160
+ ## Parameters
214
161
 
215
- ### Parameters
162
+ ### zod
216
163
 
217
- | Parameter | Type |
218
- | ------ | ------ |
219
- | `value` | `T` |
164
+ `ZodType`\<`TZod`\>
220
165
 
221
- ### Returns
166
+ The zod schema to validate against
222
167
 
223
- `T` & `TZod` \| `undefined`
168
+ ### name
224
169
 
225
- ```ts
226
- <T>(value: T, assert: ZodFactoryConfig): T & TZod;
227
- ```
170
+ `string`
228
171
 
229
- ### Type Parameters
172
+ A name used in error messages for identification
230
173
 
231
- | Type Parameter |
232
- | ------ |
233
- | `T` |
234
-
235
- ### Parameters
236
-
237
- | Parameter | Type |
238
- | ------ | ------ |
239
- | `value` | `T` |
240
- | `assert` | [`ZodFactoryConfig`](#../type-aliases/ZodFactoryConfig) |
174
+ ## Returns
241
175
 
242
- ### Returns
176
+ A function that validates and narrows the type of a value
243
177
 
244
- `T` & `TZod`
178
+ \{
179
+ \<`T`\> (`value`): `T` & `TZod` \| `undefined`;
180
+ \<`T`\> (`value`, `assert`): `T` & `TZod`;
181
+ \}
245
182
 
246
- ### <a id="zodIsFactory"></a>zodIsFactory
183
+ ### <a id="zodIsFactory"></a>zodIsFactory
247
184
 
248
185
  [**@xylabs/zod**](#../README)
249
186
 
250
187
  ***
251
188
 
252
189
  ```ts
253
- function zodIsFactory<TZod>(zod: ZodType<TZod>): <T>(value: T) => value is T & TZod;
190
+ function zodIsFactory<TZod>(zod): <T>(value) => value is T & TZod;
254
191
  ```
255
192
 
256
193
  Creates a type guard function that checks if a value matches a zod schema.
257
194
 
258
195
  ## Type Parameters
259
196
 
260
- | Type Parameter |
261
- | ------ |
262
- | `TZod` |
197
+ ### TZod
263
198
 
264
- ## Parameters
265
-
266
- | Parameter | Type | Description |
267
- | ------ | ------ | ------ |
268
- | `zod` | `ZodType`\<`TZod`\> | The zod schema to validate against |
199
+ `TZod`
269
200
 
270
- ## Returns
271
-
272
- A type guard function that returns true if the value passes validation
273
-
274
- ```ts
275
- <T>(value: T): value is T & TZod;
276
- ```
201
+ ## Parameters
277
202
 
278
- ### Type Parameters
203
+ ### zod
279
204
 
280
- | Type Parameter |
281
- | ------ |
282
- | `T` |
205
+ `ZodType`\<`TZod`\>
283
206
 
284
- ### Parameters
207
+ The zod schema to validate against
285
208
 
286
- | Parameter | Type |
287
- | ------ | ------ |
288
- | `value` | `T` |
209
+ ## Returns
289
210
 
290
- ### Returns
211
+ A type guard function that returns true if the value passes validation
291
212
 
292
- `value is T & TZod`
213
+ \<`T`\>(`value`) => `value is T & TZod`
293
214
 
294
- ### <a id="zodToAsyncFactory"></a>zodToAsyncFactory
215
+ ### <a id="zodToAsyncFactory"></a>zodToAsyncFactory
295
216
 
296
217
  [**@xylabs/zod**](#../README)
297
218
 
298
219
  ***
299
220
 
300
221
  ```ts
301
- function zodToAsyncFactory<TZod>(zod: ZodType<TZod>, name: string): {
302
- <T> (value: T): Promise<T & TZod | undefined>;
303
- <T> (value: T, assert: ZodFactoryConfig): Promise<T & TZod>;
222
+ function zodToAsyncFactory<TZod>(zod, name): {
223
+ <T> (value): Promise<T & TZod | undefined>;
224
+ <T> (value, assert): Promise<T & TZod>;
304
225
  };
305
226
  ```
306
227
 
@@ -309,72 +230,43 @@ Provides overloads for optional assertion: without assert config resolves to und
309
230
 
310
231
  ## Type Parameters
311
232
 
312
- | Type Parameter |
313
- | ------ |
314
- | `TZod` |
315
-
316
- ## Parameters
317
-
318
- | Parameter | Type | Description |
319
- | ------ | ------ | ------ |
320
- | `zod` | `ZodType`\<`TZod`\> | The zod schema to validate against |
321
- | `name` | `string` | A name used in error messages for identification |
322
-
323
- ## Returns
324
-
325
- An async function that validates and converts a value to the schema type
326
-
327
- ```ts
328
- <T>(value: T): Promise<T & TZod | undefined>;
329
- ```
330
-
331
- ### Type Parameters
233
+ ### TZod
332
234
 
333
- | Type Parameter |
334
- | ------ |
335
- | `T` |
235
+ `TZod`
336
236
 
337
- ### Parameters
338
-
339
- | Parameter | Type |
340
- | ------ | ------ |
341
- | `value` | `T` |
237
+ ## Parameters
342
238
 
343
- ### Returns
239
+ ### zod
344
240
 
345
- `Promise`\<`T` & `TZod` \| `undefined`\>
241
+ `ZodType`\<`TZod`\>
346
242
 
347
- ```ts
348
- <T>(value: T, assert: ZodFactoryConfig): Promise<T & TZod>;
349
- ```
243
+ The zod schema to validate against
350
244
 
351
- ### Type Parameters
245
+ ### name
352
246
 
353
- | Type Parameter |
354
- | ------ |
355
- | `T` |
247
+ `string`
356
248
 
357
- ### Parameters
249
+ A name used in error messages for identification
358
250
 
359
- | Parameter | Type |
360
- | ------ | ------ |
361
- | `value` | `T` |
362
- | `assert` | [`ZodFactoryConfig`](#../type-aliases/ZodFactoryConfig) |
251
+ ## Returns
363
252
 
364
- ### Returns
253
+ An async function that validates and converts a value to the schema type
365
254
 
366
- `Promise`\<`T` & `TZod`\>
255
+ \{
256
+ \<`T`\> (`value`): `Promise`\<`T` & `TZod` \| `undefined`\>;
257
+ \<`T`\> (`value`, `assert`): `Promise`\<`T` & `TZod`\>;
258
+ \}
367
259
 
368
- ### <a id="zodToFactory"></a>zodToFactory
260
+ ### <a id="zodToFactory"></a>zodToFactory
369
261
 
370
262
  [**@xylabs/zod**](#../README)
371
263
 
372
264
  ***
373
265
 
374
266
  ```ts
375
- function zodToFactory<TZod>(zod: ZodType<TZod>, name: string): {
376
- <T> (value: T): T & TZod | undefined;
377
- <T> (value: T, assert: ZodFactoryConfig): T & TZod;
267
+ function zodToFactory<TZod>(zod, name): {
268
+ <T> (value): T & TZod | undefined;
269
+ <T> (value, assert): T & TZod;
378
270
  };
379
271
  ```
380
272
 
@@ -383,65 +275,36 @@ Provides overloads for optional assertion: without assert config returns undefin
383
275
 
384
276
  ## Type Parameters
385
277
 
386
- | Type Parameter |
387
- | ------ |
388
- | `TZod` |
389
-
390
- ## Parameters
391
-
392
- | Parameter | Type | Description |
393
- | ------ | ------ | ------ |
394
- | `zod` | `ZodType`\<`TZod`\> | The zod schema to validate against |
395
- | `name` | `string` | A name used in error messages for identification |
396
-
397
- ## Returns
398
-
399
- A function that validates and converts a value to the schema type
400
-
401
- ```ts
402
- <T>(value: T): T & TZod | undefined;
403
- ```
278
+ ### TZod
404
279
 
405
- ### Type Parameters
280
+ `TZod`
406
281
 
407
- | Type Parameter |
408
- | ------ |
409
- | `T` |
282
+ ## Parameters
410
283
 
411
- ### Parameters
284
+ ### zod
412
285
 
413
- | Parameter | Type |
414
- | ------ | ------ |
415
- | `value` | `T` |
286
+ `ZodType`\<`TZod`\>
416
287
 
417
- ### Returns
288
+ The zod schema to validate against
418
289
 
419
- `T` & `TZod` \| `undefined`
290
+ ### name
420
291
 
421
- ```ts
422
- <T>(value: T, assert: ZodFactoryConfig): T & TZod;
423
- ```
292
+ `string`
424
293
 
425
- ### Type Parameters
294
+ A name used in error messages for identification
426
295
 
427
- | Type Parameter |
428
- | ------ |
429
- | `T` |
430
-
431
- ### Parameters
432
-
433
- | Parameter | Type |
434
- | ------ | ------ |
435
- | `value` | `T` |
436
- | `assert` | [`ZodFactoryConfig`](#../type-aliases/ZodFactoryConfig) |
296
+ ## Returns
437
297
 
438
- ### Returns
298
+ A function that validates and converts a value to the schema type
439
299
 
440
- `T` & `TZod`
300
+ \{
301
+ \<`T`\> (`value`): `T` & `TZod` \| `undefined`;
302
+ \<`T`\> (`value`, `assert`): `T` & `TZod`;
303
+ \}
441
304
 
442
- ### interfaces
305
+ ### interfaces
443
306
 
444
- ### <a id="ZodFactoryConfigObject"></a>ZodFactoryConfigObject
307
+ ### <a id="ZodFactoryConfigObject"></a>ZodFactoryConfigObject
445
308
 
446
309
  [**@xylabs/zod**](#../README)
447
310
 
@@ -451,32 +314,37 @@ Configuration object for zod factory functions, providing a name for error messa
451
314
 
452
315
  ## Properties
453
316
 
454
- | Property | Type |
455
- | ------ | ------ |
456
- | <a id="name"></a> `name` | `string` |
317
+ ### name
318
+
319
+ ```ts
320
+ name: string;
321
+ ```
457
322
 
458
- ### type-aliases
323
+ ### type-aliases
459
324
 
460
- ### <a id="AllZodFactories"></a>AllZodFactories
325
+ ### <a id="AllZodFactories"></a>AllZodFactories
461
326
 
462
327
  [**@xylabs/zod**](#../README)
463
328
 
464
329
  ***
465
330
 
466
331
  ```ts
467
- type AllZodFactories<TType, TName> = { [K in `is${TName}`]: ReturnType<typeof zodIsFactory> } & { [K in `as${TName}`]: ReturnType<typeof zodAsFactory> } & { [K in `to${TName}`]: ReturnType<typeof zodToFactory> };
332
+ type AllZodFactories<TType, TName> = Record<`is${TName}`, ReturnType<typeof zodIsFactory>> & Record<`as${TName}`, ReturnType<typeof zodAsFactory>> & Record<`to${TName}`, ReturnType<typeof zodToFactory>>;
468
333
  ```
469
334
 
470
335
  **`Alpha`**
471
336
 
472
337
  ## Type Parameters
473
338
 
474
- | Type Parameter |
475
- | ------ |
476
- | `TType` |
477
- | `TName` *extends* `string` |
339
+ ### TType
478
340
 
479
- ### <a id="ZodFactoryConfig"></a>ZodFactoryConfig
341
+ `TType`
342
+
343
+ ### TName
344
+
345
+ `TName` *extends* `string`
346
+
347
+ ### <a id="ZodFactoryConfig"></a>ZodFactoryConfig
480
348
 
481
349
  [**@xylabs/zod**](#../README)
482
350
 
@@ -491,41 +359,7 @@ type ZodFactoryConfig =
491
359
  Configuration for zod factory assertion behavior, either an AssertConfig or a named config object.
492
360
 
493
361
 
494
- Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
495
-
496
- ## Maintainers
497
-
498
- - [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
499
- - [Matt Jones](https://github.com/jonesmac)
500
- - [Joel Carter](https://github.com/JoelBCarter)
501
- - [Jordan Trouw](https://github.com/jordantrouw)
502
-
503
- ## License
504
-
505
- > See the [LICENSE](LICENSE) file for license details
506
-
507
- ## Credits
508
-
509
- [Made with 🔥 and ❄️ by XYLabs](https://xylabs.com)
510
-
511
- [logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
512
-
513
- [main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
514
- [main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
515
362
  [npm-badge]: https://img.shields.io/npm/v/@xylabs/zod.svg
516
363
  [npm-link]: https://www.npmjs.com/package/@xylabs/zod
517
- [codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698
518
- [codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade
519
- [codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
520
- [codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
521
- [snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
522
- [snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
523
-
524
- [npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/zod
525
- [npm-license-badge]: https://img.shields.io/npm/l/@xylabs/zod
526
-
527
- [jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/zod/badge
528
- [jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/zod
529
-
530
- [socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/zod
531
- [socket-link]: https://socket.dev/npm/package/@xylabs/zod
364
+ [license-badge]: https://img.shields.io/npm/l/@xylabs/zod.svg
365
+ [license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/zodAsFactory.ts","../../src/zodIsFactory.ts","../../src/zodToFactory.ts","../../src/zodAllFactory.ts","../../src/zodAsAsyncFactory.ts","../../src/zodToAsyncFactory.ts"],"sourcesContent":["import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\n\n/**\n * Creates a function that validates a value against a zod schema and returns it with a narrowed type.\n * When called without an assert config, returns undefined on failure. When called with an assert config, throws on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns A function that validates and narrows the type of a value\n */\nexport function zodAsFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n function asFunc<T>(value: T): (T & TZod) | undefined\n function asFunc<T>(value: T, assert: ZodFactoryConfig): (T & TZod)\n function asFunc<T>(value: T, assert?: ZodFactoryConfig): (T & TZod) | undefined {\n const result = zod.safeParse(value)\n if (result.success) {\n return value as (T & TZod)\n }\n if (assert !== undefined) {\n let assertConfig: AssertConfig\n switch (typeof assert) {\n case 'string': {\n assertConfig = `[${name}][${value}] ${assert}`\n break\n }\n case 'object': {\n assertConfig = `[${name}][${assert.name}][${value}] ${result.error.message}`\n break\n }\n case 'boolean': {\n assertConfig = `[${name}][${value}] ${result.error.message}`\n break\n }\n case 'function': {\n assertConfig = assert(value, result.error.message)\n break\n }\n }\n return assertError(value, assertConfig, result.error.message)\n }\n }\n\n return asFunc\n}\n","import type * as z from 'zod'\n\n/**\n * Creates a type guard function that checks if a value matches a zod schema.\n * @param zod - The zod schema to validate against\n * @returns A type guard function that returns true if the value passes validation\n */\nexport function zodIsFactory<TZod>(zod: z.ZodType<TZod>) {\n return <T>(value: T): value is T & TZod => zod.safeParse(value).success\n}\n","import { isDefined } from '@xylabs/typeof'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\nimport { zodAsFactory } from './zodAsFactory.ts'\n\n/**\n * Creates a function that converts a value to the zod schema type, delegating to `zodAsFactory` internally.\n * Provides overloads for optional assertion: without assert config returns undefined on failure, with assert config throws on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns A function that validates and converts a value to the schema type\n */\nexport function zodToFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n const as = zodAsFactory<TZod>(zod, name)\n function toFunc<T>(value: T): (T & TZod) | undefined\n function toFunc<T>(value: T, assert: ZodFactoryConfig): (T & TZod)\n function toFunc<T>(value: T, assert?: ZodFactoryConfig): (T & TZod) | undefined {\n if (isDefined(assert)) {\n return as(value, assert)\n }\n return as(value)\n }\n return toFunc\n}\n","import type * as z from 'zod'\n\nimport { zodAsFactory } from './zodAsFactory.ts'\nimport { zodIsFactory } from './zodIsFactory.ts'\nimport { zodToFactory } from './zodToFactory.ts'\n\n/** @alpha */\nexport type AllZodFactories<TType, TName extends string> = {\n [K in `is${TName}`]: ReturnType<typeof zodIsFactory<TType>>\n} & {\n [K in `as${TName}`]: ReturnType<typeof zodAsFactory<TType>>\n} & {\n [K in `to${TName}`]: ReturnType<typeof zodToFactory<TType>>\n}\n\n/**\n * Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schema.\n * @alpha\n * @param zod - The zod schema to validate against\n * @param name - The name used to suffix the generated function names (e.g. 'Address' produces `isAddress`, `asAddress`, `toAddress`)\n * @returns An object containing `is<Name>`, `as<Name>`, and `to<Name>` functions\n */\nexport function zodAllFactory<T, TName extends string>(zod: z.ZodType<T>, name: TName) {\n return {\n [`is${name}`]: zodIsFactory<T>(zod),\n [`as${name}`]: zodAsFactory<T>(zod, `as${name}`),\n [`to${name}`]: zodToFactory<T>(zod, `to${name}`),\n }\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\n\n/**\n * Creates an async function that validates a value against a zod schema and returns it with a narrowed type.\n * Uses `safeParseAsync` for schemas with async refinements. When called without an assert config, returns undefined on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns An async function that validates and narrows the type of a value\n */\nexport function zodAsAsyncFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n function asFunc<T>(value: T): Promise<(T & TZod) | undefined>\n function asFunc<T>(value: T, assert: ZodFactoryConfig): Promise<(T & TZod)>\n async function asFunc<T>(value: T, assert?: ZodFactoryConfig): Promise<(T & TZod) | undefined> {\n const result = await zod.safeParseAsync(value)\n if (result.success) {\n return value as (T & TZod)\n }\n if (assert !== undefined) {\n let assertConfig: AssertConfig\n switch (typeof assert) {\n case 'string': {\n assertConfig = `[${name}][${value}] ${assert}`\n break\n }\n case 'object': {\n assertConfig = `[${name}][${assert.name}][${value}] ${result.error.message}`\n break\n }\n case 'boolean': {\n assertConfig = `[${name}][${value}] ${result.error.message}`\n break\n }\n case 'function': {\n assertConfig = assert(value, result.error.message)\n break\n }\n }\n return assertError(value, assertConfig, result.error.message)\n }\n }\n\n return asFunc\n}\n","import { isDefined } from '@xylabs/typeof'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\nimport { zodAsAsyncFactory } from './zodAsAsyncFactory.ts'\n\n/**\n * Creates an async function that converts a value to the zod schema type, delegating to `zodAsAsyncFactory` internally.\n * Provides overloads for optional assertion: without assert config resolves to undefined on failure, with assert config throws on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns An async function that validates and converts a value to the schema type\n */\nexport function zodToAsyncFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n const as = zodAsAsyncFactory<TZod>(zod, name)\n function toFunc<T>(value: T): Promise<(T & TZod) | undefined>\n function toFunc<T>(value: T, assert: ZodFactoryConfig): Promise<(T & TZod)>\n async function toFunc<T>(value: T, assert?: ZodFactoryConfig): Promise<(T & TZod) | undefined> {\n if (isDefined(assert)) {\n return await as(value, assert)\n }\n return await as(value)\n }\n return toFunc\n}\n"],"mappings":";AACA,SAAS,mBAAmB;AAYrB,SAAS,aAAmB,KAAsB,MAAc;AAGrE,WAAS,OAAU,OAAU,QAAmD;AAC9E,UAAM,SAAS,IAAI,UAAU,KAAK;AAClC,QAAI,OAAO,SAAS;AAClB,aAAO;AAAA,IACT;AACA,QAAI,WAAW,QAAW;AACxB,UAAI;AACJ,cAAQ,OAAO,QAAQ;AAAA,QACrB,KAAK,UAAU;AACb,yBAAe,IAAI,IAAI,KAAK,KAAK,KAAK,MAAM;AAC5C;AAAA,QACF;AAAA,QACA,KAAK,UAAU;AACb,yBAAe,IAAI,IAAI,KAAK,OAAO,IAAI,KAAK,KAAK,KAAK,OAAO,MAAM,OAAO;AAC1E;AAAA,QACF;AAAA,QACA,KAAK,WAAW;AACd,yBAAe,IAAI,IAAI,KAAK,KAAK,KAAK,OAAO,MAAM,OAAO;AAC1D;AAAA,QACF;AAAA,QACA,KAAK,YAAY;AACf,yBAAe,OAAO,OAAO,OAAO,MAAM,OAAO;AACjD;AAAA,QACF;AAAA,MACF;AACA,aAAO,YAAY,OAAO,cAAc,OAAO,MAAM,OAAO;AAAA,IAC9D;AAAA,EACF;AAEA,SAAO;AACT;;;ACvCO,SAAS,aAAmB,KAAsB;AACvD,SAAO,CAAI,UAAgC,IAAI,UAAU,KAAK,EAAE;AAClE;;;ACTA,SAAS,iBAAiB;AAanB,SAAS,aAAmB,KAAsB,MAAc;AACrE,QAAM,KAAK,aAAmB,KAAK,IAAI;AAGvC,WAAS,OAAU,OAAU,QAAmD;AAC9E,QAAI,UAAU,MAAM,GAAG;AACrB,aAAO,GAAG,OAAO,MAAM;AAAA,IACzB;AACA,WAAO,GAAG,KAAK;AAAA,EACjB;AACA,SAAO;AACT;;;ACFO,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,MAAM,GAAG,KAAK;AAAA,EACvB;AACA,SAAO;AACT;","names":["assertError","isDefined","isDefined"]}
1
+ {"version":3,"sources":["../../src/zodAsFactory.ts","../../src/zodIsFactory.ts","../../src/zodToFactory.ts","../../src/zodAllFactory.ts","../../src/zodAsAsyncFactory.ts","../../src/zodToAsyncFactory.ts"],"sourcesContent":["import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\n\n/**\n * Creates a function that validates a value against a zod schema and returns it with a narrowed type.\n * When called without an assert config, returns undefined on failure. When called with an assert config, throws on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns A function that validates and narrows the type of a value\n */\nexport function zodAsFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n function asFunc<T>(value: T): (T & TZod) | undefined\n function asFunc<T>(value: T, assert: ZodFactoryConfig): (T & TZod)\n function asFunc<T>(value: T, assert?: ZodFactoryConfig): (T & TZod) | undefined {\n const result = zod.safeParse(value)\n if (result.success) {\n return value as (T & TZod)\n }\n if (assert !== undefined) {\n let assertConfig: AssertConfig\n switch (typeof assert) {\n case 'string': {\n assertConfig = `[${name}][${value}] ${assert}`\n break\n }\n case 'object': {\n assertConfig = `[${name}][${assert.name}][${value}] ${result.error.message}`\n break\n }\n case 'boolean': {\n assertConfig = `[${name}][${value}] ${result.error.message}`\n break\n }\n case 'function': {\n assertConfig = assert(value, result.error.message)\n break\n }\n }\n return assertError(value, assertConfig, result.error.message)\n }\n }\n\n return asFunc\n}\n","import type * as z from 'zod'\n\n/**\n * Creates a type guard function that checks if a value matches a zod schema.\n * @param zod - The zod schema to validate against\n * @returns A type guard function that returns true if the value passes validation\n */\nexport function zodIsFactory<TZod>(zod: z.ZodType<TZod>) {\n return <T>(value: T): value is T & TZod => zod.safeParse(value).success\n}\n","import { isDefined } from '@xylabs/typeof'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\nimport { zodAsFactory } from './zodAsFactory.ts'\n\n/**\n * Creates a function that converts a value to the zod schema type, delegating to `zodAsFactory` internally.\n * Provides overloads for optional assertion: without assert config returns undefined on failure, with assert config throws on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns A function that validates and converts a value to the schema type\n */\nexport function zodToFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n const as = zodAsFactory<TZod>(zod, name)\n function toFunc<T>(value: T): (T & TZod) | undefined\n function toFunc<T>(value: T, assert: ZodFactoryConfig): (T & TZod)\n function toFunc<T>(value: T, assert?: ZodFactoryConfig): (T & TZod) | undefined {\n if (isDefined(assert)) {\n return as(value, assert)\n }\n return as(value)\n }\n return toFunc\n}\n","import type * as z from 'zod'\n\nimport { zodAsFactory } from './zodAsFactory.ts'\nimport { zodIsFactory } from './zodIsFactory.ts'\nimport { zodToFactory } from './zodToFactory.ts'\n\n/** @alpha */\nexport type AllZodFactories<TType, TName extends string>\n = Record<`is${TName}`, ReturnType<typeof zodIsFactory<TType>>>\n & Record<`as${TName}`, ReturnType<typeof zodAsFactory<TType>>>\n & Record<`to${TName}`, ReturnType<typeof zodToFactory<TType>>>\n\n/**\n * Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schema.\n * @alpha\n * @param zod - The zod schema to validate against\n * @param name - The name used to suffix the generated function names (e.g. 'Address' produces `isAddress`, `asAddress`, `toAddress`)\n * @returns An object containing `is<Name>`, `as<Name>`, and `to<Name>` functions\n */\nexport function zodAllFactory<T, TName extends string>(zod: z.ZodType<T>, name: TName) {\n return {\n [`is${name}`]: zodIsFactory<T>(zod),\n [`as${name}`]: zodAsFactory<T>(zod, `as${name}`),\n [`to${name}`]: zodToFactory<T>(zod, `to${name}`),\n }\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\n\n/**\n * Creates an async function that validates a value against a zod schema and returns it with a narrowed type.\n * Uses `safeParseAsync` for schemas with async refinements. When called without an assert config, returns undefined on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns An async function that validates and narrows the type of a value\n */\nexport function zodAsAsyncFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n function asFunc<T>(value: T): Promise<(T & TZod) | undefined>\n function asFunc<T>(value: T, assert: ZodFactoryConfig): Promise<(T & TZod)>\n async function asFunc<T>(value: T, assert?: ZodFactoryConfig): Promise<(T & TZod) | undefined> {\n const result = await zod.safeParseAsync(value)\n if (result.success) {\n return value as (T & TZod)\n }\n if (assert !== undefined) {\n let assertConfig: AssertConfig\n switch (typeof assert) {\n case 'string': {\n assertConfig = `[${name}][${value}] ${assert}`\n break\n }\n case 'object': {\n assertConfig = `[${name}][${assert.name}][${value}] ${result.error.message}`\n break\n }\n case 'boolean': {\n assertConfig = `[${name}][${value}] ${result.error.message}`\n break\n }\n case 'function': {\n assertConfig = assert(value, result.error.message)\n break\n }\n }\n return assertError(value, assertConfig, result.error.message)\n }\n }\n\n return asFunc\n}\n","import { isDefined } from '@xylabs/typeof'\nimport type * as z from 'zod'\n\nimport type { ZodFactoryConfig } from './Config.ts'\nimport { zodAsAsyncFactory } from './zodAsAsyncFactory.ts'\n\n/**\n * Creates an async function that converts a value to the zod schema type, delegating to `zodAsAsyncFactory` internally.\n * Provides overloads for optional assertion: without assert config resolves to undefined on failure, with assert config throws on failure.\n * @param zod - The zod schema to validate against\n * @param name - A name used in error messages for identification\n * @returns An async function that validates and converts a value to the schema type\n */\nexport function zodToAsyncFactory<TZod>(zod: z.ZodType<TZod>, name: string) {\n const as = zodAsAsyncFactory<TZod>(zod, name)\n function toFunc<T>(value: T): Promise<(T & TZod) | undefined>\n function toFunc<T>(value: T, assert: ZodFactoryConfig): Promise<(T & TZod)>\n async function toFunc<T>(value: T, assert?: ZodFactoryConfig): Promise<(T & TZod) | undefined> {\n if (isDefined(assert)) {\n return await as(value, assert)\n }\n return await as(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} from './zodIsFactory.ts';
4
4
  import { zodToFactory } from './zodToFactory.ts';
5
5
  /** @alpha */
6
- export type AllZodFactories<TType, TName extends string> = {
7
- [K in `is${TName}`]: ReturnType<typeof zodIsFactory<TType>>;
8
- } & {
9
- [K in `as${TName}`]: ReturnType<typeof zodAsFactory<TType>>;
10
- } & {
11
- [K in `to${TName}`]: ReturnType<typeof zodToFactory<TType>>;
12
- };
6
+ export type AllZodFactories<TType, TName extends string> = Record<`is${TName}`, ReturnType<typeof zodIsFactory<TType>>> & Record<`as${TName}`, ReturnType<typeof zodAsFactory<TType>>> & Record<`to${TName}`, ReturnType<typeof zodToFactory<TType>>>;
13
7
  /**
14
8
  * Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schema.
15
9
  * @alpha
@@ -1 +1 @@
1
- {"version":3,"file":"zodAllFactory.d.ts","sourceRoot":"","sources":["../../src/zodAllFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAA;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,aAAa;AACb,MAAM,MAAM,eAAe,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,IAAI;KACxD,CAAC,IAAI,KAAK,KAAK,EAAE,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;CAC5D,GAAG;KACD,CAAC,IAAI,KAAK,KAAK,EAAE,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;CAC5D,GAAG;KACD,CAAC,IAAI,KAAK,KAAK,EAAE,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;CAC5D,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK;;;;;EAMpF"}
1
+ {"version":3,"file":"zodAllFactory.d.ts","sourceRoot":"","sources":["../../src/zodAllFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAA;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,aAAa;AACb,MAAM,MAAM,eAAe,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,IACnD,MAAM,CAAC,KAAK,KAAK,EAAE,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAC1D,MAAM,CAAC,KAAK,KAAK,EAAE,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAC5D,MAAM,CAAC,KAAK,KAAK,EAAE,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAElE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK;;;;;EAMpF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/zod",
3
- "version": "5.0.94",
3
+ "version": "5.0.96",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -22,12 +22,10 @@
22
22
  "exports": {
23
23
  ".": {
24
24
  "types": "./dist/neutral/index.d.ts",
25
- "import": "./dist/neutral/index.mjs",
26
25
  "default": "./dist/neutral/index.mjs"
27
26
  },
28
27
  "./package.json": "./package.json"
29
28
  },
30
- "types": "./dist/neutral/index.d.ts",
31
29
  "files": [
32
30
  "dist",
33
31
  "!**/*.bench.*",
@@ -36,24 +34,25 @@
36
34
  "README.md"
37
35
  ],
38
36
  "dependencies": {
39
- "@xylabs/error": "~5.0.94",
40
- "@xylabs/typeof": "~5.0.94"
37
+ "@xylabs/typeof": "~5.0.96",
38
+ "@xylabs/error": "~5.0.96"
41
39
  },
42
40
  "devDependencies": {
43
- "@types/node": "^25.5.2",
44
- "@xylabs/ts-scripts-common": "~7.7.3",
45
- "@xylabs/ts-scripts-pnpm": "~7.7.3",
46
- "@xylabs/tsconfig": "~7.7.3",
47
- "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
41
+ "@types/node": "^25.6.0",
42
+ "@xylabs/toolchain": "~7.10.4",
43
+ "@xylabs/tsconfig": "~7.10.4",
48
44
  "esbuild": "^0.28.0",
49
45
  "typescript": "^5",
50
- "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
51
- "vitest": "^4.1.2",
46
+ "vite": "^8.0.8",
47
+ "vitest": "^4.1.4",
52
48
  "zod": "^4.3.6"
53
49
  },
54
50
  "peerDependencies": {
55
51
  "zod": "^4"
56
52
  },
53
+ "engines": {
54
+ "node": ">=18"
55
+ },
57
56
  "publishConfig": {
58
57
  "access": "public"
59
58
  }