@fluixi/forms-zod 0.2.1-alpha.1 → 1.0.0-alpha.100
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/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Validator, ValidationError, FieldControl, FormControl } from '@fluixi/forms-core';
|
|
2
2
|
interface ZodIssue {
|
|
3
|
-
|
|
3
|
+
/** Zod 4 types it as PropertyKey[]: a symbol key is possible. */
|
|
4
|
+
path: ReadonlyArray<PropertyKey>;
|
|
4
5
|
message: string;
|
|
5
6
|
code: string;
|
|
6
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* Typing: `z.infer<typeof schema>` is the form value type, so values/errors stay typed.
|
|
10
10
|
*/
|
|
11
11
|
import { createField, createForm } from '@fluixi/forms-core';
|
|
12
|
+
/** `a.0.b`. Through String(): join() throws on a symbol key. */
|
|
13
|
+
const joinPath = (path) => path.map(String).join('.');
|
|
12
14
|
const mapIssue = (issue) => ({
|
|
13
15
|
type: issue.code || 'zod',
|
|
14
16
|
message: issue.message,
|
|
15
|
-
meta: { path: issue.path
|
|
17
|
+
meta: { path: joinPath(issue.path) },
|
|
16
18
|
});
|
|
17
19
|
/**
|
|
18
20
|
* A group-level validator from a Zod schema. The returned errors carry `meta.path` so a
|
|
@@ -38,7 +40,7 @@ export function zodErrorsByPath(schema, value) {
|
|
|
38
40
|
if (res.success)
|
|
39
41
|
return out;
|
|
40
42
|
for (const issue of res.error?.issues ?? []) {
|
|
41
|
-
const key = issue.path
|
|
43
|
+
const key = joinPath(issue.path);
|
|
42
44
|
(out[key] ??= []).push(mapIssue(issue));
|
|
43
45
|
}
|
|
44
46
|
return out;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluixi/forms-zod",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.100",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Zod schema adapter for @fluixi/forms-core.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@fluixi/forms-core": "0.
|
|
21
|
+
"@fluixi/forms-core": "1.0.0-alpha.100"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"registry": "https://registry.npmjs.org/",
|