@softistx/alxia-zod 0.0.0-stage → 0.3.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Steve Tsala
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # @softistx/alxia-zod
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Moved from `@alxia/zod`: see the [migration guide](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/migrating-from-alxia-scope.md).
4
+
5
+ [Zod 4](https://zod.dev) for [alxia](https://www.npmjs.com/package/@softistx/alxia).
6
+ `@softistx/alxia` validates with any Standard Schema and imports no validator;
7
+ this package adds what only Zod can: coercions of the text a request
8
+ carries, typed by what a client means to send, and a Zod schema as JSON
9
+ Schema, as it crosses the wire.
10
+
11
+ ```sh
12
+ bun add @softistx/alxia-zod zod
13
+ bun add -d typescript
14
+ ```
15
+
16
+ `zod` is a peer: your app's own copy is the one used.
17
+
18
+ ## Coercions: `zq`
19
+
20
+ Path parameters, the query string, headers and cookies arrive as text.
21
+ `z.coerce.number()` reads them, but its input is `unknown`. `zq` reads the
22
+ same text, and its input is the value a client means to send:
23
+
24
+ ```ts
25
+ import { validate } from '@softistx/alxia';
26
+ import { zq } from '@softistx/alxia-zod';
27
+ import { z } from 'zod';
28
+
29
+ app.get('/search/:page', validate({
30
+ params: z.object({ page: zq.int() }),
31
+ query: z.object({
32
+ tags: zq.array(z.string()).optional(), // ?tags=a and ?tags=a&tags=b
33
+ exact: zq.boolean().optional(), // true/false/1/0
34
+ since: zq.date().optional(), // ISO 8601
35
+ filter: zq.json(Filter).optional(), // ?filter={"min":3}
36
+ }),
37
+ }), ...);
38
+
39
+ await app.request(`/search/2?exact=true&since=${new Date().toISOString()}`);
40
+ ```
41
+
42
+ | | the server reads | the client sends |
43
+ | --- | --- | --- |
44
+ | `zq.number()` | `number` | `number \| string` |
45
+ | `zq.int()` | an integer | `number \| string` |
46
+ | `zq.boolean()` | `boolean` | `boolean \| 'true' \| 'false' \| '1' \| '0'` |
47
+ | `zq.date()` | `Date` | `Date \| string` |
48
+ | `zq.array(item)` | `Item[]`, from one value or many | `Item \| Item[]` |
49
+ | `zq.json(schema)` | the schema's output | the schema's input, sent as JSON; an array as its JSON text, `JSON.stringify(ids)` |
50
+
51
+ ## API
52
+
53
+ | export | |
54
+ | --- | --- |
55
+ | `zq` | `number`, `int`, `boolean`, `date`, `array`, `json` |
56
+
57
+ ## Documentation
58
+
59
+ - [Guide](https://github.com/softistx/alxia/tree/develop/packages/zod/docs): what each coercion accepts, refuses and lets a client send.
60
+ - [Troubleshooting](https://github.com/softistx/alxia/blob/develop/packages/zod/docs/troubleshooting.md): a validation message or a `tsc` error, and what to do about it.
61
+ - [Roadmap](https://github.com/softistx/alxia/blob/develop/packages/zod/docs/roadmap.md): what is coming, and what is not planned.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Schemas for what arrives as text — path parameters, the query string,
3
+ * headers, cookies — whose input is the value a client means to send. A
4
+ * client sends `{ page: 2 }`, never `{ page: '2' }`, and the server reads a
5
+ * number, where `z.coerce.number()` would type the client's side `unknown`.
6
+ */
7
+ import { z } from 'zod';
8
+ /** A number, given as one or as its text. */
9
+ declare function number(): z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>;
10
+ /** An integer, given as one or as its text. */
11
+ declare function int(): z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>, z.ZodNumber>;
12
+ /** A boolean: `true`, `false`, or `'true'`, `'false'`, `'1'`, `'0'`. */
13
+ declare function boolean(): z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
14
+ 1: "1";
15
+ true: "true";
16
+ 0: "0";
17
+ false: "false";
18
+ }>]>, z.ZodTransform<boolean, boolean | "1" | "true" | "0" | "false">>;
19
+ /** A date: a `Date`, or ISO 8601 text, which is how a client sends one. */
20
+ declare function date(): z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodDate, z.ZodISODateTime, z.ZodISODate]>, z.ZodTransform<Date, string | Date>>, z.ZodDate>;
21
+ /**
22
+ * A list a query key gives: `?tag=a` reads `['a']`, `?tag=a&tag=b`
23
+ * `['a', 'b']` — where `z.array` refuses the first.
24
+ */
25
+ declare function array<Item extends z.ZodType>(item: Item): z.ZodPipe<z.ZodUnion<readonly [Item, z.ZodArray<Item>]>, z.ZodTransform<z.output<Item>[], z.core.output<Item>[] | z.core.$InferUnionOutput<Item>>>;
26
+ /**
27
+ * A value given as JSON text: a filter in a query string. A client gives
28
+ * the value itself, sent as its JSON; an array goes as JSON text, since a
29
+ * query sends a list as repeated keys.
30
+ */
31
+ declare function json<Schema extends z.ZodType>(schema: Schema): z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<unknown, string>>, z.ZodCustom<Exclude<z.core.input<Schema>, readonly unknown[]>, Exclude<z.core.input<Schema>, readonly unknown[]>>]>, Schema>;
32
+ /** The coercions, as one namespace: `zq.int()`, `zq.array(z.string())`. */
33
+ export declare const zq: {
34
+ number: typeof number;
35
+ int: typeof int;
36
+ boolean: typeof boolean;
37
+ date: typeof date;
38
+ array: typeof array;
39
+ json: typeof json;
40
+ };
41
+ export {};
42
+ //# sourceMappingURL=coerce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,6CAA6C;AAC7C,iBAAS,MAAM,gIAOd;AAED,+CAA+C;AAC/C,iBAAS,GAAG,wJAEX;AAED,wEAAwE;AACxE,iBAAS,OAAO;;;;;uEAMf;AAED,2EAA2E;AAC3E,iBAAS,IAAI,2IAOZ;AAED;;;GAGG;AACH,iBAAS,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,sJAYhD;AAED;;;;GAIG;AACH,iBAAS,IAAI,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,wNAmBrD;AAED,2EAA2E;AAC3E,eAAO,MAAM,EAAE;;;;;;;CAA8C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { zq } from './coerce';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ // src/coerce.ts
2
+ import { z } from "zod";
3
+ var NUMERIC = /^\s*[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?\s*$/i;
4
+ function branchMessage(index, fallback) {
5
+ return (issue) => issue.errors?.[typeof index === "number" ? index : index(issue.input)]?.[0]?.message ?? fallback;
6
+ }
7
+ function number() {
8
+ return z.union([z.number(), z.string().regex(NUMERIC, "Expected a number")], {
9
+ error: () => "Expected a number"
10
+ }).transform(Number).pipe(z.number());
11
+ }
12
+ function int() {
13
+ return number().pipe(z.number().int("Expected an integer"));
14
+ }
15
+ function boolean() {
16
+ return z.union([z.boolean(), z.enum(["true", "false", "1", "0"])], {
17
+ error: () => "Expected true, false, 1 or 0"
18
+ }).transform((value) => value === true || value === "true" || value === "1");
19
+ }
20
+ function date() {
21
+ return z.union([z.date(), z.iso.datetime({ offset: true }), z.iso.date()], {
22
+ error: () => "Expected an ISO 8601 date or date-time"
23
+ }).transform((value) => value instanceof Date ? value : new Date(value)).pipe(z.date());
24
+ }
25
+ function array(item) {
26
+ return z.union([item, z.array(item)], {
27
+ error: branchMessage((input) => Array.isArray(input) ? 1 : 0, "Expected a value or a list of them")
28
+ }).transform((value) => Array.isArray(value) ? value : [value]);
29
+ }
30
+ function json(schema) {
31
+ return z.union([
32
+ z.string().transform((text, ctx) => {
33
+ try {
34
+ return JSON.parse(text);
35
+ } catch {
36
+ ctx.addIssue({ code: "custom", message: "Expected JSON" });
37
+ return z.NEVER;
38
+ }
39
+ }),
40
+ z.custom((value) => typeof value !== "string")
41
+ ], { error: branchMessage(0, "Expected JSON") }).pipe(schema);
42
+ }
43
+ var zq = { number, int, boolean, date, array, json };
44
+ export {
45
+ zq
46
+ };
47
+
48
+ //# debugId=DD893E9F91CFBB0E64756E2164756E21
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/coerce.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Schemas for what arrives as text — path parameters, the query string,\n * headers, cookies — whose input is the value a client means to send. A\n * client sends `{ page: 2 }`, never `{ page: '2' }`, and the server reads a\n * number, where `z.coerce.number()` would type the client's side `unknown`.\n */\nimport { z } from 'zod';\n\nconst NUMERIC = /^\\s*[-+]?(\\d+\\.?\\d*|\\.\\d+)(e[-+]?\\d+)?\\s*$/i;\n\n/**\n * A union's own message in place of Zod's `Invalid input`: the first issue\n * of the branch `index` chooses for the input refused, or `fallback`.\n */\nfunction branchMessage(\n\tindex: number | ((input: unknown) => number),\n\tfallback: string,\n) {\n\treturn (issue: {\n\t\treadonly input?: unknown;\n\t\treadonly errors?: readonly (readonly { message: string }[])[];\n\t}) =>\n\t\tissue.errors?.[typeof index === 'number' ? index : index(issue.input)]?.[0]\n\t\t\t?.message ?? fallback;\n}\n\n/** A number, given as one or as its text. */\nfunction number() {\n\treturn z\n\t\t.union([z.number(), z.string().regex(NUMERIC, 'Expected a number')], {\n\t\t\terror: () => 'Expected a number',\n\t\t})\n\t\t.transform(Number)\n\t\t.pipe(z.number());\n}\n\n/** An integer, given as one or as its text. */\nfunction int() {\n\treturn number().pipe(z.number().int('Expected an integer'));\n}\n\n/** A boolean: `true`, `false`, or `'true'`, `'false'`, `'1'`, `'0'`. */\nfunction boolean() {\n\treturn z\n\t\t.union([z.boolean(), z.enum(['true', 'false', '1', '0'])], {\n\t\t\terror: () => 'Expected true, false, 1 or 0',\n\t\t})\n\t\t.transform((value) => value === true || value === 'true' || value === '1');\n}\n\n/** A date: a `Date`, or ISO 8601 text, which is how a client sends one. */\nfunction date() {\n\treturn z\n\t\t.union([z.date(), z.iso.datetime({ offset: true }), z.iso.date()], {\n\t\t\terror: () => 'Expected an ISO 8601 date or date-time',\n\t\t})\n\t\t.transform((value) => (value instanceof Date ? value : new Date(value)))\n\t\t.pipe(z.date());\n}\n\n/**\n * A list a query key gives: `?tag=a` reads `['a']`, `?tag=a&tag=b`\n * `['a', 'b']` — where `z.array` refuses the first.\n */\nfunction array<Item extends z.ZodType>(item: Item) {\n\treturn z\n\t\t.union([item, z.array(item)], {\n\t\t\t// Why what was given was refused: the one value, or the list.\n\t\t\terror: branchMessage(\n\t\t\t\t(input) => (Array.isArray(input) ? 1 : 0),\n\t\t\t\t'Expected a value or a list of them',\n\t\t\t),\n\t\t})\n\t\t.transform(\n\t\t\t(value) => (Array.isArray(value) ? value : [value]) as z.output<Item>[],\n\t\t);\n}\n\n/**\n * A value given as JSON text: a filter in a query string. A client gives\n * the value itself, sent as its JSON; an array goes as JSON text, since a\n * query sends a list as repeated keys.\n */\nfunction json<Schema extends z.ZodType>(schema: Schema) {\n\treturn z\n\t\t.union(\n\t\t\t[\n\t\t\t\tz.string().transform((text, ctx) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn JSON.parse(text) as unknown;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tctx.addIssue({ code: 'custom', message: 'Expected JSON' });\n\t\t\t\t\t\treturn z.NEVER;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tz.custom<Exclude<z.input<Schema>, readonly unknown[]>>(\n\t\t\t\t\t(value) => typeof value !== 'string',\n\t\t\t\t),\n\t\t\t],\n\t\t\t{ error: branchMessage(0, 'Expected JSON') },\n\t\t)\n\t\t.pipe(schema);\n}\n\n/** The coercions, as one namespace: `zq.int()`, `zq.array(z.string())`. */\nexport const zq = { number, int, boolean, date, array, json };\n"
6
+ ],
7
+ "mappings": ";AAMA;AAEA,IAAM,UAAU;AAMhB,SAAS,aAAa,CACrB,OACA,UACC;AAAA,EACD,OAAO,CAAC,UAIP,MAAM,SAAS,OAAO,UAAU,WAAW,QAAQ,MAAM,MAAM,KAAK,KAAK,IACtE,WAAW;AAAA;AAIhB,SAAS,MAAM,GAAG;AAAA,EACjB,OAAO,EACL,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,MAAM,SAAS,mBAAmB,CAAC,GAAG;AAAA,IACpE,OAAO,MAAM;AAAA,EACd,CAAC,EACA,UAAU,MAAM,EAChB,KAAK,EAAE,OAAO,CAAC;AAAA;AAIlB,SAAS,GAAG,GAAG;AAAA,EACd,OAAO,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,qBAAqB,CAAC;AAAA;AAI3D,SAAS,OAAO,GAAG;AAAA,EAClB,OAAO,EACL,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,KAAK,CAAC,QAAQ,SAAS,KAAK,GAAG,CAAC,CAAC,GAAG;AAAA,IAC1D,OAAO,MAAM;AAAA,EACd,CAAC,EACA,UAAU,CAAC,UAAU,UAAU,QAAQ,UAAU,UAAU,UAAU,GAAG;AAAA;AAI3E,SAAS,IAAI,GAAG;AAAA,EACf,OAAO,EACL,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,IAAI,SAAS,EAAE,QAAQ,KAAK,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,GAAG;AAAA,IAClE,OAAO,MAAM;AAAA,EACd,CAAC,EACA,UAAU,CAAC,UAAW,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK,CAAE,EACtE,KAAK,EAAE,KAAK,CAAC;AAAA;AAOhB,SAAS,KAA6B,CAAC,MAAY;AAAA,EAClD,OAAO,EACL,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,GAAG;AAAA,IAE7B,OAAO,cACN,CAAC,UAAW,MAAM,QAAQ,KAAK,IAAI,IAAI,GACvC,oCACD;AAAA,EACD,CAAC,EACA,UACA,CAAC,UAAW,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,CAClD;AAAA;AAQF,SAAS,IAA8B,CAAC,QAAgB;AAAA,EACvD,OAAO,EACL,MACA;AAAA,IACC,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,QAAQ;AAAA,MACnC,IAAI;AAAA,QACH,OAAO,KAAK,MAAM,IAAI;AAAA,QACrB,MAAM;AAAA,QACP,IAAI,SAAS,EAAE,MAAM,UAAU,SAAS,gBAAgB,CAAC;AAAA,QACzD,OAAO,EAAE;AAAA;AAAA,KAEV;AAAA,IACD,EAAE,OACD,CAAC,UAAU,OAAO,UAAU,QAC7B;AAAA,EACD,GACA,EAAE,OAAO,cAAc,GAAG,eAAe,EAAE,CAC5C,EACC,KAAK,MAAM;AAAA;AAIP,IAAM,KAAK,EAAE,QAAQ,KAAK,SAAS,MAAM,OAAO,KAAK;",
8
+ "debugId": "DD893E9F91CFBB0E64756E2164756E21",
9
+ "names": []
10
+ }
package/docs/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @softistx/alxia-zod documentation
2
+
3
+ The [package README](../README.md) is the short version. This folder is
4
+ the long one: what each coercion accepts and refuses, what a client may send
5
+ for it, and what to do
6
+ when a request a client typed is still answered with a `400`.
7
+
8
+ | Page | Read it when |
9
+ | --- | --- |
10
+ | [Guide](guide.md) | reading a number, a boolean, a date, a list or a JSON filter from the path, the query string, a header or a cookie; or testing a route that reads them |
11
+ | [Troubleshooting](troubleshooting.md) | a request is refused with a `400` and you have its issue message, `tsc` refused a `zq` call |
12
+ | [Roadmap](roadmap.md) | wondering what is coming, and what is not planned |
package/docs/guide.md ADDED
@@ -0,0 +1,357 @@
1
+ # Guide
2
+
3
+ This page covers what `@softistx/alxia-zod` adds to an alxia app: the `zq`
4
+ coercions, which read the text a request carries as the values a client
5
+ means to send.
6
+
7
+ ```ts
8
+ import { alxia, validate } from '@softistx/alxia';
9
+ import { zq } from '@softistx/alxia-zod';
10
+ import { z } from 'zod';
11
+
12
+ const app = alxia().get(
13
+ '/items/:id',
14
+ validate({ params: z.object({ id: zq.int() }) }),
15
+ ({ params, reply }) => reply(200, { id: params.id, next: params.id + 1 }),
16
+ );
17
+
18
+ const result = await app.request('/items/41');
19
+ await result.json(); // { id: 41, next: 42 }
20
+ ```
21
+
22
+ The path arrives as the text `'41'`; the handler reads the number `41`, and
23
+ the schema's input, `number | string`, says a client may send the number
24
+ itself, not a string it would have to format.
25
+
26
+ ## The signature
27
+
28
+ ```ts
29
+ import type { z } from 'zod';
30
+
31
+ // Each coercion is a Zod schema. Its input is what the client may send,
32
+ // its output what the handler reads:
33
+ //
34
+ // z.input (the client sends) z.output (the server reads)
35
+ // zq.number() number | string number
36
+ // zq.int() number | string number, an integer
37
+ // zq.boolean() boolean | 'true' | 'false' | '1' | '0' boolean
38
+ // zq.date() Date | string Date
39
+ // zq.array(item) z.input<item> | z.input<item>[] z.output<item>[]
40
+ // zq.json(schema) string | z.input<schema> z.output<schema>
41
+ // (an array schema: string only)
42
+
43
+ declare const zq: {
44
+ number(): z.ZodType<number, number | string>;
45
+ int(): z.ZodType<number, number | string>;
46
+ boolean(): z.ZodType<boolean, boolean | 'true' | 'false' | '1' | '0'>;
47
+ date(): z.ZodType<Date, Date | string>;
48
+ array<Item extends z.ZodType>(item: Item): z.ZodType<z.output<Item>[], z.input<Item> | z.input<Item>[]>;
49
+ json<Schema extends z.ZodType>(schema: Schema): z.ZodType<z.output<Schema>, string | Exclude<z.input<Schema>, readonly unknown[]>>;
50
+ };
51
+ ```
52
+
53
+ The published types are the exact Zod pipes and unions these stand for, so
54
+ `.optional()`, `.default()`, `.describe()` and the rest of Zod's methods are
55
+ there as on any schema.
56
+
57
+ ## Coercions: `zq`
58
+
59
+ Path parameters, the query string, headers and cookies are text. Zod's own
60
+ `z.coerce.number()` reads that text, but its input is `unknown`, so a typed
61
+ client accepts anything for the key. `z.number()` has the right input,
62
+ but refuses the text the server receives. A `zq` coercion does both: its
63
+ input is the value, the server accepts the value or its text.
64
+
65
+ | | `z.number()` | `z.coerce.number()` | `zq.number()` |
66
+ | --- | --- | --- | --- |
67
+ | the client may send | `number` | anything | `number \| string` |
68
+ | `?n=2` on the server | refused: `expected number, received string` | `2` | `2` |
69
+ | `?n=abc` on the server | refused | refused | refused: `Expected a number` |
70
+
71
+ Use them wherever a value arrives as text: `params`, `query`, `headers`,
72
+ `cookies`, and the fields of a form body. A JSON body already carries
73
+ numbers, booleans and arrays, so `z.number()` is right there.
74
+
75
+ ```ts
76
+ app.get(
77
+ '/reports',
78
+ validate({
79
+ query: z.object({ year: zq.int(), draft: zq.boolean().optional() }),
80
+ headers: z.object({ 'x-page-size': zq.int().default(20) }),
81
+ cookies: z.object({ beta: zq.boolean().default(false) }),
82
+ }),
83
+ ({ query, headers, cookies, reply }) =>
84
+ reply(200, { year: query.year, size: headers['x-page-size'], beta: cookies.beta }),
85
+ );
86
+ ```
87
+
88
+ A client sends a value as text the coercion reads back: a number or a boolean with `String`, a `Date` with `toISOString()`, an
89
+ object as JSON, and each item of an array under the same key.
90
+
91
+ ### `zq.number()`
92
+
93
+ A number, or the text of one: an optional sign, digits with an optional
94
+ decimal point, an optional exponent, and surrounding spaces.
95
+
96
+ ```ts
97
+ zq.number().parse('3'); // 3
98
+ zq.number().parse(' -2.5 '); // -2.5
99
+ zq.number().parse('.5'); // 0.5
100
+ zq.number().parse('1e3'); // 1000
101
+ zq.number().parse(7); // 7
102
+ ```
103
+
104
+ Anything else is refused with the message `Expected a number`: the empty
105
+ string, `'abc'`, `'0x10'`, `'Infinity'`, `'NaN'`. Unlike `Number('')`, an
106
+ empty value is never read as `0`.
107
+
108
+ Chain a check with `.pipe`, since the coercion's output is a plain
109
+ `z.number()`:
110
+
111
+ ```ts
112
+ const price = zq.number().pipe(z.number().positive());
113
+ ```
114
+
115
+ ### `zq.int()`
116
+
117
+ `zq.number()`, then an integer. `'2'` reads `2`; text that is not a number
118
+ is refused with `Expected a number`, and `'1.5'` and `2.5` with
119
+ `Expected an integer`. It is the
120
+ usual choice for an id in the path, a page, a limit:
121
+
122
+ ```ts
123
+ const Page = z.object({
124
+ page: zq.int().pipe(z.number().min(1)).default(1),
125
+ limit: zq.int().pipe(z.number().max(100)).default(20),
126
+ });
127
+ ```
128
+
129
+ ### `zq.boolean()`
130
+
131
+ `true` or `false`, or one of the texts `'true'`, `'false'`, `'1'`, `'0'`:
132
+
133
+ ```ts
134
+ zq.boolean().parse('true'); // true
135
+ zq.boolean().parse('0'); // false
136
+ zq.boolean().parse(false); // false
137
+ ```
138
+
139
+ Anything else is refused with `Expected true, false, 1 or 0`: `'yes'`, `'TRUE'`,
140
+ `'on'`, and the empty string, so `?draft=` is an error rather than a silent
141
+ `false`. Compare `z.coerce.boolean()`, which reads `'false'` as `true`,
142
+ since any non-empty string is truthy.
143
+
144
+ A flag that may be absent is `.optional()`, or `.default(false)` to read a
145
+ `boolean` either way.
146
+
147
+ ### `zq.date()`
148
+
149
+ A `Date`, or ISO 8601 text: a date and time with `Z` or an offset, or a
150
+ date alone.
151
+
152
+ ```ts
153
+ zq.date().parse('2026-01-01T00:00:00Z'); // 2026-01-01T00:00:00.000Z
154
+ zq.date().parse('2026-01-01T00:00:00+02:00'); // 2025-12-31T22:00:00.000Z
155
+ zq.date().parse('2026-01-01'); // 2026-01-01T00:00:00.000Z, midnight UTC
156
+ zq.date().parse(new Date(0)); // the same Date
157
+ ```
158
+
159
+ Refused, with `Expected an ISO 8601 date or date-time`:
160
+
161
+ - a date and time with no offset, `'2026-01-01T10:00'` — which is what an
162
+ HTML `datetime-local` input gives; it names no instant, so it is not
163
+ guessed at (see [Troubleshooting](troubleshooting.md#expected-an-iso-8601-date-or-date-time));
164
+ - a timestamp, `'1767225600000'`;
165
+ - anything `Date` would parse loosely, `'tomorrow'`, `'Jan 1 2026'`;
166
+ - an invalid `Date` object.
167
+
168
+ A client sends a `Date` as its `toISOString()`, which always reads back.
169
+
170
+ ### `zq.array(item)`
171
+
172
+ A list a key gives once or more. The server reads the query string with a
173
+ key given once as a string and a key given more than once as an array of
174
+ them; `z.array` refuses the first, so a list of one fails. `zq.array` takes
175
+ both:
176
+
177
+ ```ts
178
+ const Tags = zq.array(z.string());
179
+
180
+ Tags.parse('a'); // ['a'] ?tag=a
181
+ Tags.parse(['a', 'b']); // ['a', 'b'] ?tag=a&tag=b
182
+ ```
183
+
184
+ The item is any schema, a coercion included:
185
+
186
+ ```ts
187
+ const Ids = zq.array(zq.int());
188
+ Ids.parse('1'); // [1]
189
+ Ids.parse(['1', '2']); // [1, 2]
190
+
191
+ const Statuses = zq.array(z.enum(['open', 'paid', 'shipped']));
192
+ ```
193
+
194
+ A refused list reports the first issue of what was refused: the one value
195
+ given, or the list. Given once (`?ids=x`), the issue is on the key: path
196
+ `["ids"]`, `Expected a number`. Given more than once (`?ids=1&ids=x`), each
197
+ refused item is its own issue at its index, path `["ids", 1]`, when the
198
+ item is a plain schema such as `zq.int()`, `zq.number()` or `z.string()`. For an item that
199
+ is itself a union or an object — `z.enum(…)`, `zq.date()`, `zq.boolean()`,
200
+ `z.object(…)` — the issue is `invalid_union` on the key, with the item's
201
+ message: its index, or its inner path, is not kept.
202
+
203
+ An absent key is `undefined`, not `[]`: make the list `.optional()`, or
204
+ `.default([])`.
205
+
206
+ ### `zq.json(schema)`
207
+
208
+ A value given as JSON text, then validated by `schema`: a filter, a range,
209
+ a sort in the query string.
210
+
211
+ ```ts
212
+ const Range = zq.json(z.object({ min: z.number(), max: z.number() }));
213
+
214
+ Range.parse('{"min":1,"max":5}'); // { min: 1, max: 5 }
215
+ Range.parse({ min: 1, max: 5 }); // { min: 1, max: 5 }, already parsed
216
+ ```
217
+
218
+ A client typed by the schema's input sends an object as its JSON text,
219
+ `?range={"min":1,"max":5}`. Text that is not JSON
220
+ is refused with `Expected JSON`; JSON that does not match the schema is
221
+ refused with the schema's own issue, at the path inside it:
222
+
223
+ ```text
224
+ ?range={"min":"x","max":5} → path ["range", "min"]: Invalid input: expected number, received string
225
+ ```
226
+
227
+ An array is the exception: its input is its JSON
228
+ text, a `string`, not as the array. A query sends a list as one value per
229
+ key, `?ids=1&ids=2`, which is not JSON, so an array given as itself could
230
+ never reach the schema:
231
+
232
+ ```ts
233
+ const app = alxia().get(
234
+ '/ids',
235
+ validate({ query: z.object({ ids: zq.json(z.array(z.number())) }) }),
236
+ ({ query, reply }) => reply(200, query.ids), // number[]
237
+ );
238
+
239
+ await app.request(`/ids?${new URLSearchParams({ ids: JSON.stringify([1, 2]) })}`); // ?ids=[1,2]
240
+ ```
241
+
242
+ For a list a key repeats, use [`zq.array(item)`](#zqarrayitem) instead.
243
+ A plain string does not suit `zq.json` either: see
244
+ [Troubleshooting](troubleshooting.md#expected-json).
245
+
246
+ ## What a refusal looks like
247
+
248
+ A value a coercion refuses fails the route's validation like any other: the
249
+ handler does not run, and the route answers its `400`, with one issue per
250
+ problem. From `GET /items/x`:
251
+
252
+ ```json
253
+ {
254
+ "error": "validation",
255
+ "issues": [
256
+ { "target": "params", "path": ["id"], "code": "invalid_format", "message": "Expected a number" }
257
+ ]
258
+ }
259
+ ```
260
+
261
+ | Coercion | Refused value | `code` | `message` |
262
+ | --- | --- | --- | --- |
263
+ | `number`, `int` | text that is not a number | `invalid_format` | `Expected a number` |
264
+ | `number`, `int` | neither a number nor text, such as an object | `invalid_union` | `Expected a number` |
265
+ | `int` | a number that is not an integer | `invalid_type` | `Expected an integer` |
266
+ | `boolean` | text other than the four | `invalid_union` | `Expected true, false, 1 or 0` |
267
+ | `date` | text that is not ISO 8601 with an offset, or a date | `invalid_union` | `Expected an ISO 8601 date or date-time` |
268
+ | `json` | text that is not JSON | `invalid_union` | `Expected JSON` |
269
+ | `json` | JSON the schema refuses | the schema's | the schema's, at its path |
270
+ | `array` | a key given once, which the item schema refuses | `invalid_union` | the item's, on the key: `Expected a number` for `zq.int()` |
271
+ | `array` | a key given more than once, one of them refused | the item's, or `invalid_union` | the item's: at its index (`["ids", 1]`) for `zq.int()` or `z.string()`; on the key, without the index, for an enum, `zq.date()`, `zq.boolean()` or an object |
272
+
273
+ A client typed by the schema's input refuses most of these at compile
274
+ time; the `400` is what a hand-written URL, a link, or another client gets.
275
+
276
+ ## A realistic setup
277
+
278
+ A list of orders a page filters by status, date and total, and its tests
279
+ through `app.request()`:
280
+
281
+ ```ts
282
+ // app.ts
283
+ import { alxia, responds, validate } from '@softistx/alxia';
284
+ import { zq } from '@softistx/alxia-zod';
285
+ import { z } from 'zod';
286
+
287
+ export const Order = z.object({
288
+ id: z.string(),
289
+ status: z.enum(['open', 'paid', 'shipped']),
290
+ total: z.number(),
291
+ createdAt: z.date(),
292
+ });
293
+
294
+ const orders: z.output<typeof Order>[] = [
295
+ { id: 'a1', status: 'paid', total: 40, createdAt: new Date('2026-03-01T09:00:00Z') },
296
+ { id: 'a2', status: 'open', total: 12, createdAt: new Date('2026-03-02T09:00:00Z') },
297
+ ];
298
+
299
+ export const app = alxia().get(
300
+ '/orders',
301
+ validate({
302
+ query: z.object({
303
+ page: zq.int().default(1),
304
+ status: zq.array(Order.shape.status).optional(),
305
+ since: zq.date().optional(),
306
+ total: zq.json(z.object({ min: z.number(), max: z.number() })).optional(),
307
+ }),
308
+ }),
309
+ responds({ 200: z.object({ page: z.number(), items: z.array(Order) }) }),
310
+ ({ query, reply }) =>
311
+ reply(200, {
312
+ page: query.page,
313
+ items: orders.filter(
314
+ (order) =>
315
+ (query.status === undefined || query.status.includes(order.status)) &&
316
+ (query.since === undefined || order.createdAt >= query.since) &&
317
+ (query.total === undefined ||
318
+ (order.total >= query.total.min && order.total <= query.total.max)),
319
+ ),
320
+ }),
321
+ );
322
+ ```
323
+
324
+ ```ts
325
+ // app.spec.ts
326
+ import { describe, expect, test } from 'bun:test';
327
+ import { app } from './app';
328
+
329
+ describe('GET /orders', () => {
330
+ test('values sent as text, read typed by the route', async () => {
331
+ const query = new URLSearchParams([
332
+ ['status', 'paid'],
333
+ ['status', 'open'],
334
+ ['since', new Date('2026-03-01T00:00:00Z').toISOString()],
335
+ ['total', JSON.stringify({ min: 10, max: 50 })],
336
+ ]);
337
+ const result = await app.request(`/orders?${query}`);
338
+ expect(result.status).toBe(200);
339
+ expect(await result.json()).toMatchObject({ page: 1, items: [{ id: 'a1' }, { id: 'a2' }] });
340
+ });
341
+
342
+ test('one status is a list of one', async () => {
343
+ const response = await app.request('/orders?status=paid');
344
+ expect(await response.json()).toMatchObject({
345
+ items: [{ id: 'a1', createdAt: '2026-03-01T09:00:00.000Z' }],
346
+ });
347
+ });
348
+
349
+ test('a page that is not an integer is a 400', async () => {
350
+ const response = await app.request('/orders?page=1.5');
351
+ expect(response.status).toBe(400);
352
+ });
353
+ });
354
+ ```
355
+
356
+ When a request is still refused, [Troubleshooting](troubleshooting.md)
357
+ starts from the issue message in the `400`.
@@ -0,0 +1,55 @@
1
+ # Roadmap
2
+
3
+ What `@softistx/alxia-zod` gives an app, and what is coming. This page is a
4
+ direction, not a commitment: the version something shipped in is the only
5
+ number on it. Every release, with each change it made, is in
6
+ [`CHANGELOG.md`](https://github.com/softistx/alxia/blob/develop/packages/zod/CHANGELOG.md).
7
+
8
+ ## Now
9
+
10
+ - **Moving to the `@softistx` scope.** The package is now `@softistx/alxia-zod` (it was `@alxia/zod`). Same code and API; replace the dependency and the imports ([migration guide](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/migrating-from-alxia-scope.md)). The old name is deprecated.
11
+
12
+ ## Next
13
+
14
+ Nothing scheduled yet.
15
+
16
+ ## Later
17
+
18
+ Nothing scheduled yet.
19
+
20
+ ## Not planned
21
+
22
+ - **Zod inside `@softistx/alxia`.** It reads any Standard
23
+ Schema and names no validator, so an app can use Zod, Valibot, ArkType or
24
+ its own; what only Zod can do lives in this package.
25
+ - **A runtime dependency.** `@softistx/alxia-zod` declares no dependency, only
26
+ peers: the app's own `zod` is the one used.
27
+
28
+ ## Shipped
29
+
30
+ ### 0.2.0
31
+
32
+ - **`zodConverter` removed in 0.2.** Nothing in alxia read it: Zod's own
33
+ `z.toJSONSchema(schema)` converts a schema.
34
+
35
+ ### 0.1.0
36
+
37
+ - **Coercions a client can type.** `zq.number()`, `zq.int()`,
38
+ `zq.boolean()` and `zq.date()` read the text of the path, the query
39
+ string, headers and cookies as a number, an integer, a boolean or a
40
+ `Date`, while a typed client sends the value itself — `{ page: 2 }`, not
41
+ `{ page: '2' }`, and never `unknown`.
42
+ - **Strict reading.** An empty value is not `0`, `'false'` is `false`,
43
+ and a date and time without an offset is refused rather than guessed.
44
+ - **Refusals that say what was expected.** A refused value reports
45
+ `Expected a number`, `Expected an integer`, `Expected true, false, 1 or 0`,
46
+ `Expected an ISO 8601 date or date-time` or `Expected JSON`, and a
47
+ refused list reports what was refused — the value given, or each refused
48
+ item at its index — never Zod's bare `Invalid input`.
49
+ - **Lists of one.** `zq.array(item)` reads `?tag=a` as `['a']` and
50
+ `?tag=a&tag=b` as `['a', 'b']`, where `z.array` refuses the first.
51
+ - **JSON in the query string.** `zq.json(schema)` reads a filter sent as
52
+ JSON, validates it with the schema, and lets the client send the object.
53
+ An array is sent as its JSON text, since a query sends a list as repeated
54
+ keys.
55
+ - **JSON Schema that matches the wire.** `zodConverter`, removed in 0.2.
@@ -0,0 +1,219 @@
1
+ # Troubleshooting
2
+
3
+ Each entry is headed by the text you see: the `message` of an issue in a
4
+ route's `400`, an error from `tsc`, or, for a trap that prints nothing, what
5
+ you notice. A `400` from validation reads like this, and the heading is its
6
+ `message`:
7
+
8
+ ```json
9
+ {
10
+ "error": "validation",
11
+ "issues": [{ "target": "query", "path": ["page"], "code": "invalid_format", "message": "Expected a number" }]
12
+ }
13
+ ```
14
+
15
+ **A `400` from validation**
16
+
17
+ - [`Expected a number`](#expected-a-number)
18
+ - [`Expected an integer`](#expected-an-integer)
19
+ - [`Expected true, false, 1 or 0`](#expected-true-false-1-or-0)
20
+ - [`Expected an ISO 8601 date or date-time`](#expected-an-iso-8601-date-or-date-time)
21
+ - [`Expected JSON`](#expected-json)
22
+ - [`Invalid input: expected number, received string`](#invalid-input-expected-number-received-string)
23
+ - [`Invalid input: expected array, received string`](#invalid-input-expected-array-received-string)
24
+
25
+ **Wrong values, no error**
26
+
27
+ - [`?draft=false` reads `true`](#draftfalse-reads-true)
28
+ - [A typed client accepts anything for a key](#a-typed-client-accepts-anything-for-a-key)
29
+
30
+ **Types**
31
+
32
+ - [`Expected 1 arguments, but got 0.`](#expected-1-arguments-but-got-0)
33
+
34
+
35
+ ## A `400` from validation
36
+
37
+ ### `Expected a number`
38
+
39
+ **When:** a key read by `zq.number()` or `zq.int()` is given text that is
40
+ not a number: `/items/abc`, `?page=`, `?limit=0x10`, `?n=Infinity`. Or an
41
+ item of a `zq.array(zq.int())` is: `?ids=x` reports it on the key, path
42
+ `["ids"]`; `?ids=1&ids=x` at the item's index, path `["ids", 1]`.
43
+
44
+ **Why:** the coercion accepts a number, or the text of one — digits, with
45
+ an optional sign, decimal point and exponent — and nothing else. An empty
46
+ value is refused rather than read as `0`.
47
+
48
+ **Fix:** send a number. When the key is optional, leave it out rather than
49
+ sending it empty:
50
+
51
+ ```ts
52
+ const query = new URLSearchParams(input.value === '' ? {} : { page: input.value });
53
+ await fetch(`/items?${query}`);
54
+ ```
55
+
56
+ If the key is not a number at all — a slug, an id with letters — it is a
57
+ `z.string()`, not a coercion.
58
+
59
+ ### `Expected an integer`
60
+
61
+ **When:** `zq.int()` is given a number with a fraction: `?page=1.5`.
62
+
63
+ **Why:** `zq.int()` reads the number, then refuses anything but an integer.
64
+
65
+ **Fix:** send an integer, or accept fractions with `zq.number()`:
66
+
67
+ ```ts
68
+ const query = z.object({ page: zq.int(), price: zq.number() });
69
+ ```
70
+
71
+ ### `Invalid input: expected number, received string`
72
+
73
+ **When:** a key in `params`, `query`, `headers` or `cookies` is a plain
74
+ `z.number()` — or a `z.array(z.number())`. Or a hand-written URL repeats a
75
+ key read by `zq.json(z.array(z.number()))`: `?ids=1&ids=2`, path
76
+ `["ids", 0]`.
77
+
78
+ **Why:** everything in a URL, a header or a cookie is text, and
79
+ `z.number()` refuses text. A client typed by the schema's input is happy,
80
+ since that input is a `number`, so the error only shows at run time. A
81
+ repeated key is a list of texts, `'1'` and `'2'`, not JSON, so `zq.json`
82
+ hands them to the schema as they are: send the array as its JSON text,
83
+ `?ids=[1,2]`.
84
+
85
+ **Fix:** use the coercion, and `zq.array` for a list:
86
+
87
+ ```ts
88
+ const query = z.object({
89
+ min: zq.number(),
90
+ ids: zq.array(zq.int()),
91
+ });
92
+ ```
93
+
94
+ ### `Invalid input: expected array, received string`
95
+
96
+ **When:** a list is a `z.array(...)`, and the key is given once:
97
+ `?tag=a`.
98
+
99
+ **Why:** the query string reads a key given once as a string, and a key
100
+ given more than once as an array. `z.array` accepts only the second, so a
101
+ list of one is refused.
102
+
103
+ **Fix:**
104
+
105
+ ```ts
106
+ const query = z.object({ tag: zq.array(z.string()) }); // ?tag=a → ['a'], ?tag=a&tag=b → ['a', 'b']
107
+ ```
108
+
109
+ ### `Expected true, false, 1 or 0`
110
+
111
+ **When:** `zq.boolean()` is given anything but `true`, `false`, `'true'`,
112
+ `'false'`, `'1'` or `'0'`: `?draft=yes`, `?draft=TRUE`, `?draft=on`, or
113
+ `?draft=` with no value. An HTML checkbox sends `on`. In a
114
+ `zq.array(zq.boolean())`, the issue is on the key, without the index of the
115
+ refused item, whether the key was given once or more.
116
+
117
+ **Why:** the four texts are the only ones read; anything else is refused,
118
+ not guessed.
119
+
120
+ **Fix:** send one of the four — a boolean as `'true'` or `'false'`. For a checkbox in a form, read its presence instead:
121
+
122
+ ```ts
123
+ const form = z.object({ draft: z.literal('on').optional().transform((value) => value === 'on') });
124
+ ```
125
+
126
+ ### `Expected an ISO 8601 date or date-time`
127
+
128
+ **When:** `zq.date()` is given text that is not ISO 8601 with an offset or
129
+ a date alone: `?since=2026-01-01T10:00` (what an HTML `datetime-local`
130
+ input gives), `?since=1767225600000`, `?since=tomorrow`. In a
131
+ `zq.array(zq.date())`, the issue is on the key, without the index of the
132
+ refused item, whether the key was given once or more.
133
+
134
+ **Why:** a date and time without `Z` or an offset names no instant — it
135
+ depends on a time zone the server does not know — so it is refused rather
136
+ than read in the server's zone. A timestamp and loose text are refused too.
137
+
138
+ **Fix:** send a `Date` as its `toISOString()`. A `datetime-local` value
139
+ becomes one in the browser, in the user's zone:
140
+
141
+ ```ts
142
+ await fetch(`/orders?${new URLSearchParams({ since: new Date(input.value).toISOString() })}`);
143
+ ```
144
+
145
+ A date alone, `?since=2026-01-01`, is accepted, and reads midnight UTC.
146
+
147
+ ### `Expected JSON`
148
+
149
+ **When:** a key read by `zq.json(schema)` is given text that is not JSON:
150
+ `?filter={`, `?filter=min:3`, or `?ids=x` for a `zq.json(z.array(...))`.
151
+ Or `schema` is a `z.string()`, and the client sends a plain string.
152
+
153
+ **Why:** the text is parsed with `JSON.parse` before `schema` sees it, and
154
+ text that does not parse is refused. A client sends an object as its JSON,
155
+ but a string as it is, so `zq.json(z.string())` receives `abc`, which is not
156
+ JSON; it would need `"abc"`, quotes included.
157
+
158
+ **Fix:** send the object and let the client encode it. A plain string needs
159
+ no `zq.json`:
160
+
161
+ ```ts
162
+ const query = z.object({
163
+ filter: zq.json(z.object({ min: z.number() })), // client: { filter: { min: 3 } }
164
+ name: z.string(), // not zq.json(z.string())
165
+ });
166
+ ```
167
+
168
+ When the JSON parses but the schema refuses it, the issue is the schema's
169
+ own, at its path inside the value: `path: ["filter", "min"]`.
170
+
171
+ ## Wrong values, no error
172
+
173
+ ### `?draft=false` reads `true`
174
+
175
+ **When:** a flag is a `z.coerce.boolean()`.
176
+
177
+ **Why:** `z.coerce.boolean()` is `Boolean(value)`, and every non-empty
178
+ string is truthy, `'false'` and `'0'` included.
179
+
180
+ **Fix:**
181
+
182
+ ```ts
183
+ const query = z.object({ draft: zq.boolean().default(false) }); // 'false' and '0' read false
184
+ ```
185
+
186
+ ### A typed client accepts anything for a key
187
+
188
+ **When:** a key is a `z.coerce.number()`, `z.coerce.boolean()` or
189
+ `z.coerce.date()`. A client typed by the schema's input accepts
190
+ `{ page: 'two' }` or `{ page: {} }` without a complaint, and the server
191
+ refuses it at run time.
192
+
193
+ **Why:** a `z.coerce` schema's input is `unknown`.
194
+
195
+ **Fix:** use the `zq` coercion, whose input is the value or its text:
196
+
197
+ ```ts
198
+ const params = z.object({ page: zq.int() }); // the client sends number | string
199
+ ```
200
+
201
+ ## Types
202
+
203
+ ### `Expected 1 arguments, but got 0.`
204
+
205
+ ```text
206
+ error TS2554: Expected 1 arguments, but got 0.
207
+ ```
208
+
209
+ **When:** `zq.array()` or `zq.json()` with no schema.
210
+
211
+ **Why:** each wraps a schema: the item of the list, the value inside the
212
+ JSON.
213
+
214
+ **Fix:**
215
+
216
+ ```ts
217
+ zq.array(z.string());
218
+ zq.json(z.object({ min: z.number() }));
219
+ ```
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
- "name": "@softistx/alxia-zod",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@softistx/alxia-zod",
3
+ "version": "0.3.0",
4
+ "description": "Zod 4 for alxia: query and path coercions typed by what a client sends",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "docs",
12
+ "README.md",
13
+ "package.json",
14
+ "LICENSE"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/softistx/alxia.git",
27
+ "directory": "packages/zod"
28
+ },
29
+ "publishConfig": {
30
+ "registry": "https://registry.npmjs.org",
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "bun run ../../build.ts",
35
+ "test": "bun test src",
36
+ "typecheck": "tsc --noEmit"
37
+ },
38
+ "alxia": {
39
+ "entrypoints": [
40
+ "src/index.ts"
41
+ ]
42
+ },
43
+ "devDependencies": {
44
+ "@softistx/alxia": "^0.28.0",
45
+ "@types/bun": "^1.4.4",
46
+ "zod": "^4.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "typescript": "^6.0.3 || ^7.0.0",
50
+ "zod": "^4.2.0"
51
+ }
52
+ }