@conform-to/yup 0.3.0 → 0.3.1
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 +7 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
> [Yup](https://github.com/jquense/yup) schema resolver for [conform](https://github.com/edmundhung/conform)
|
|
4
4
|
|
|
5
|
+
<!-- aside -->
|
|
6
|
+
|
|
5
7
|
## API Reference
|
|
6
8
|
|
|
7
9
|
- [resolve](#resolve)
|
|
8
10
|
|
|
11
|
+
<!-- /aside -->
|
|
12
|
+
|
|
9
13
|
### resolve
|
|
10
14
|
|
|
11
15
|
It resolves yup schema to a conform schema:
|
|
@@ -15,7 +19,7 @@ import { useForm, useFieldset } from '@conform-to/react';
|
|
|
15
19
|
import { resolve } from '@conform-to/yup';
|
|
16
20
|
import * as yup from 'yup';
|
|
17
21
|
|
|
18
|
-
// Define the schema with
|
|
22
|
+
// Define the schema with yup
|
|
19
23
|
const schema = resolve(
|
|
20
24
|
yup.object({
|
|
21
25
|
email: yup.string().required(),
|
|
@@ -32,7 +36,7 @@ function ExampleForm() {
|
|
|
32
36
|
// Read the FormData from the from
|
|
33
37
|
const payload = new FormData(e.target);
|
|
34
38
|
|
|
35
|
-
// Parse the data against the
|
|
39
|
+
// Parse the data against the yup schema
|
|
36
40
|
const submission = schema.parse(payload);
|
|
37
41
|
|
|
38
42
|
// It could be accepted / rejected / modified
|
|
@@ -49,7 +53,7 @@ function ExampleForm() {
|
|
|
49
53
|
};
|
|
50
54
|
})
|
|
51
55
|
const [setupFieldset, { email, password }] = useFieldset({
|
|
52
|
-
//
|
|
56
|
+
// Optional: setup native constraint inferred from the schema
|
|
53
57
|
constraint: schema.constraint
|
|
54
58
|
});
|
|
55
59
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@conform-to/yup",
|
|
3
3
|
"description": "Conform schema resolver for yup",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.1",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "module/index.js",
|
|
8
8
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "https://github.com/edmundhung/conform/issues"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@conform-to/dom": "0.3.
|
|
17
|
+
"@conform-to/dom": "0.3.1",
|
|
18
18
|
"yup": ">=0.32.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|