@conform-to/yup 0.9.1 → 1.0.0-pre.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/index.d.ts +6 -6
- package/index.js +4 -2
- package/index.mjs +5 -3
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Constraint, type Intent, type Submission } from '@conform-to/dom';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
|
-
export declare function getFieldsetConstraint<Source extends yup.AnyObjectSchema>(source: Source):
|
|
3
|
+
export declare function getFieldsetConstraint<Source extends yup.AnyObjectSchema>(source: Source): Record<string, Constraint>;
|
|
4
4
|
export declare function parse<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: {
|
|
5
|
-
schema: Schema | ((
|
|
5
|
+
schema: Schema | ((intents: Array<Intent> | null) => Schema);
|
|
6
6
|
async?: false;
|
|
7
|
-
}): Submission<yup.InferType<Schema
|
|
7
|
+
}): Submission<yup.InferType<Schema>, string[]>;
|
|
8
8
|
export declare function parse<Schema extends yup.AnyObjectSchema>(payload: FormData | URLSearchParams, config: {
|
|
9
|
-
schema: Schema | ((
|
|
9
|
+
schema: Schema | ((intents: Array<Intent> | null) => Schema);
|
|
10
10
|
async: true;
|
|
11
|
-
}): Promise<Submission<yup.InferType<Schema
|
|
11
|
+
}): Promise<Submission<yup.InferType<Schema>, string[]>>;
|
package/index.js
CHANGED
|
@@ -70,12 +70,14 @@ function getFieldsetConstraint(source) {
|
|
|
70
70
|
constraint.required = true;
|
|
71
71
|
break;
|
|
72
72
|
case 'min':
|
|
73
|
+
dom.invariant(typeof constraint.min !== 'string', 'min is not a number');
|
|
73
74
|
if (!constraint.min || constraint.min < Number((_test$params6 = _test.params) === null || _test$params6 === void 0 ? void 0 : _test$params6.min)) {
|
|
74
75
|
var _test$params7;
|
|
75
76
|
constraint.min = Number((_test$params7 = _test.params) === null || _test$params7 === void 0 ? void 0 : _test$params7.min);
|
|
76
77
|
}
|
|
77
78
|
break;
|
|
78
79
|
case 'max':
|
|
80
|
+
dom.invariant(typeof constraint.max !== 'string', 'max is not a number');
|
|
79
81
|
if (!constraint.max || constraint.max > Number((_test$params8 = _test.params) === null || _test$params8 === void 0 ? void 0 : _test$params8.max)) {
|
|
80
82
|
var _test$params9;
|
|
81
83
|
constraint.max = Number((_test$params9 = _test.params) === null || _test$params9 === void 0 ? void 0 : _test$params9.max);
|
|
@@ -90,8 +92,8 @@ function getFieldsetConstraint(source) {
|
|
|
90
92
|
}
|
|
91
93
|
function parse(payload, config) {
|
|
92
94
|
return dom.parse(payload, {
|
|
93
|
-
resolve(payload,
|
|
94
|
-
var schema = typeof config.schema === 'function' ? config.schema(
|
|
95
|
+
resolve(payload, intents) {
|
|
96
|
+
var schema = typeof config.schema === 'function' ? config.schema(intents) : config.schema;
|
|
95
97
|
var resolveData = value => ({
|
|
96
98
|
value
|
|
97
99
|
});
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse as parse$1 } from '@conform-to/dom';
|
|
1
|
+
import { invariant, parse as parse$1 } from '@conform-to/dom';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
3
|
|
|
4
4
|
function getFieldsetConstraint(source) {
|
|
@@ -46,12 +46,14 @@ function getFieldsetConstraint(source) {
|
|
|
46
46
|
constraint.required = true;
|
|
47
47
|
break;
|
|
48
48
|
case 'min':
|
|
49
|
+
invariant(typeof constraint.min !== 'string', 'min is not a number');
|
|
49
50
|
if (!constraint.min || constraint.min < Number((_test$params6 = _test.params) === null || _test$params6 === void 0 ? void 0 : _test$params6.min)) {
|
|
50
51
|
var _test$params7;
|
|
51
52
|
constraint.min = Number((_test$params7 = _test.params) === null || _test$params7 === void 0 ? void 0 : _test$params7.min);
|
|
52
53
|
}
|
|
53
54
|
break;
|
|
54
55
|
case 'max':
|
|
56
|
+
invariant(typeof constraint.max !== 'string', 'max is not a number');
|
|
55
57
|
if (!constraint.max || constraint.max > Number((_test$params8 = _test.params) === null || _test$params8 === void 0 ? void 0 : _test$params8.max)) {
|
|
56
58
|
var _test$params9;
|
|
57
59
|
constraint.max = Number((_test$params9 = _test.params) === null || _test$params9 === void 0 ? void 0 : _test$params9.max);
|
|
@@ -66,8 +68,8 @@ function getFieldsetConstraint(source) {
|
|
|
66
68
|
}
|
|
67
69
|
function parse(payload, config) {
|
|
68
70
|
return parse$1(payload, {
|
|
69
|
-
resolve(payload,
|
|
70
|
-
var schema = typeof config.schema === 'function' ? config.schema(
|
|
71
|
+
resolve(payload, intents) {
|
|
72
|
+
var schema = typeof config.schema === 'function' ? config.schema(intents) : config.schema;
|
|
71
73
|
var resolveData = value => ({
|
|
72
74
|
value
|
|
73
75
|
});
|
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": "1.0.0-pre.1",
|
|
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": "1.0.0-pre.1",
|
|
29
29
|
"yup": ">=0.32.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|