@conform-to/yup 0.7.3 → 0.8.0-pre.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/README.md +2 -2
- package/index.d.ts +0 -10
- package/index.js +2 -10
- package/index.mjs +2 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ function ExampleForm() {
|
|
|
65
65
|
Or when parsing the formData on server side (e.g. Remix):
|
|
66
66
|
|
|
67
67
|
```tsx
|
|
68
|
-
import { useForm } from '@conform-to/react';
|
|
68
|
+
import { useForm, report } from '@conform-to/react';
|
|
69
69
|
import { parse } from '@conform-to/yup';
|
|
70
70
|
import * as yup from 'yup';
|
|
71
71
|
|
|
@@ -84,7 +84,7 @@ export async function action({ request }) {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
if (!submission.value || submission.intent !== 'submit') {
|
|
87
|
-
return submission;
|
|
87
|
+
return report(submission);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// ...
|
package/index.d.ts
CHANGED
|
@@ -3,19 +3,9 @@ import * as yup from 'yup';
|
|
|
3
3
|
export declare function getFieldsetConstraint<Source extends yup.AnyObjectSchema>(source: Source): FieldsetConstraint<yup.InferType<Source>>;
|
|
4
4
|
export declare function parse<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: {
|
|
5
5
|
schema: Schema | ((intent: string) => Schema);
|
|
6
|
-
acceptMultipleErrors?: ({ name, intent, payload, }: {
|
|
7
|
-
name: string;
|
|
8
|
-
intent: string;
|
|
9
|
-
payload: Record<string, any>;
|
|
10
|
-
}) => boolean;
|
|
11
6
|
async?: false;
|
|
12
7
|
}): Submission<yup.InferType<Schema>>;
|
|
13
8
|
export declare function parse<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: {
|
|
14
9
|
schema: Schema | ((intent: string) => Schema);
|
|
15
|
-
acceptMultipleErrors?: ({ name, intent, payload, }: {
|
|
16
|
-
name: string;
|
|
17
|
-
intent: string;
|
|
18
|
-
payload: Record<string, any>;
|
|
19
|
-
}) => boolean;
|
|
20
10
|
async: true;
|
|
21
11
|
}): Promise<Submission<yup.InferType<Schema>>>;
|
package/index.js
CHANGED
|
@@ -99,17 +99,9 @@ function parse(payload, config) {
|
|
|
99
99
|
if (error instanceof yup__namespace.ValidationError) {
|
|
100
100
|
return {
|
|
101
101
|
error: error.inner.reduce((result, e) => {
|
|
102
|
-
var _e$path,
|
|
102
|
+
var _e$path, _result$name;
|
|
103
103
|
var name = (_e$path = e.path) !== null && _e$path !== void 0 ? _e$path : '';
|
|
104
|
-
|
|
105
|
-
result[name] = e.message;
|
|
106
|
-
} else if ((_config$acceptMultipl = config.acceptMultipleErrors) !== null && _config$acceptMultipl !== void 0 && _config$acceptMultipl.call(config, {
|
|
107
|
-
name,
|
|
108
|
-
intent,
|
|
109
|
-
payload
|
|
110
|
-
})) {
|
|
111
|
-
result[name] = [].concat(result[name], e.message);
|
|
112
|
-
}
|
|
104
|
+
result[name] = [...((_result$name = result[name]) !== null && _result$name !== void 0 ? _result$name : []), e.message];
|
|
113
105
|
return result;
|
|
114
106
|
}, {})
|
|
115
107
|
};
|
package/index.mjs
CHANGED
|
@@ -75,17 +75,9 @@ function parse(payload, config) {
|
|
|
75
75
|
if (error instanceof yup.ValidationError) {
|
|
76
76
|
return {
|
|
77
77
|
error: error.inner.reduce((result, e) => {
|
|
78
|
-
var _e$path,
|
|
78
|
+
var _e$path, _result$name;
|
|
79
79
|
var name = (_e$path = e.path) !== null && _e$path !== void 0 ? _e$path : '';
|
|
80
|
-
|
|
81
|
-
result[name] = e.message;
|
|
82
|
-
} else if ((_config$acceptMultipl = config.acceptMultipleErrors) !== null && _config$acceptMultipl !== void 0 && _config$acceptMultipl.call(config, {
|
|
83
|
-
name,
|
|
84
|
-
intent,
|
|
85
|
-
payload
|
|
86
|
-
})) {
|
|
87
|
-
result[name] = [].concat(result[name], e.message);
|
|
88
|
-
}
|
|
80
|
+
result[name] = [...((_result$name = result[name]) !== null && _result$name !== void 0 ? _result$name : []), e.message];
|
|
89
81
|
return result;
|
|
90
82
|
}, {})
|
|
91
83
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Conform helpers for integrating with yup",
|
|
4
4
|
"homepage": "https://conform.guide",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.8.0-pre.0",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"module": "index.mjs",
|
|
9
9
|
"types": "index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/edmundhung/conform/issues"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@conform-to/dom": "0.
|
|
28
|
+
"@conform-to/dom": "0.8.0-pre.0",
|
|
29
29
|
"yup": ">=0.32.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|