@conform-to/valibot 1.15.1 → 1.17.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 +1 -1
- package/dist/constraint.js +11 -1
- package/dist/constraint.mjs +11 -1
- package/dist/future.d.ts +4 -0
- package/dist/future.js +3 -0
- package/dist/future.mjs +1 -0
- package/dist/schema.d.ts +17 -0
- package/dist/schema.js +26 -0
- package/dist/schema.mjs +21 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
Version 1.
|
|
10
|
+
Version 1.17.0 / License MIT / Copyright (c) 2025 Edmund Hung
|
|
11
11
|
|
|
12
12
|
Progressively enhance HTML forms with React. Build resilient, type-safe forms with no hassle using web standards.
|
|
13
13
|
|
package/dist/constraint.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
|
|
7
|
-
var keys = ['required', 'minLength', 'maxLength', 'min', 'max', 'step', 'multiple', 'pattern'];
|
|
7
|
+
var keys = ['required', 'minLength', 'maxLength', 'min', 'max', 'step', 'multiple', 'pattern', 'accept'];
|
|
8
8
|
function getValibotConstraint(schema) {
|
|
9
9
|
function updateConstraint(schema, data) {
|
|
10
10
|
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
@@ -119,6 +119,16 @@ function getValibotConstraint(schema) {
|
|
|
119
119
|
// @ts-expect-error
|
|
120
120
|
updateConstraint(schema.items[i], data, "".concat(name, "[").concat(i, "]"));
|
|
121
121
|
}
|
|
122
|
+
} else if (schema.type === 'file' || schema.type === 'blob') {
|
|
123
|
+
var _schema$pipe5;
|
|
124
|
+
// @ts-expect-error
|
|
125
|
+
var mimeTypeValidation = (_schema$pipe5 = schema.pipe) === null || _schema$pipe5 === void 0 ? void 0 : _schema$pipe5.find(
|
|
126
|
+
// @ts-expect-error
|
|
127
|
+
v => 'type' in v && v.type === 'mime_type');
|
|
128
|
+
if (mimeTypeValidation && 'requirement' in mimeTypeValidation) {
|
|
129
|
+
var requirement = mimeTypeValidation.requirement;
|
|
130
|
+
constraint.accept = requirement.join();
|
|
131
|
+
}
|
|
122
132
|
} else ;
|
|
123
133
|
}
|
|
124
134
|
var result = {};
|
package/dist/constraint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
2
|
|
|
3
|
-
var keys = ['required', 'minLength', 'maxLength', 'min', 'max', 'step', 'multiple', 'pattern'];
|
|
3
|
+
var keys = ['required', 'minLength', 'maxLength', 'min', 'max', 'step', 'multiple', 'pattern', 'accept'];
|
|
4
4
|
function getValibotConstraint(schema) {
|
|
5
5
|
function updateConstraint(schema, data) {
|
|
6
6
|
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
@@ -115,6 +115,16 @@ function getValibotConstraint(schema) {
|
|
|
115
115
|
// @ts-expect-error
|
|
116
116
|
updateConstraint(schema.items[i], data, "".concat(name, "[").concat(i, "]"));
|
|
117
117
|
}
|
|
118
|
+
} else if (schema.type === 'file' || schema.type === 'blob') {
|
|
119
|
+
var _schema$pipe5;
|
|
120
|
+
// @ts-expect-error
|
|
121
|
+
var mimeTypeValidation = (_schema$pipe5 = schema.pipe) === null || _schema$pipe5 === void 0 ? void 0 : _schema$pipe5.find(
|
|
122
|
+
// @ts-expect-error
|
|
123
|
+
v => 'type' in v && v.type === 'mime_type');
|
|
124
|
+
if (mimeTypeValidation && 'requirement' in mimeTypeValidation) {
|
|
125
|
+
var requirement = mimeTypeValidation.requirement;
|
|
126
|
+
constraint.accept = requirement.join();
|
|
127
|
+
}
|
|
118
128
|
} else ;
|
|
119
129
|
}
|
|
120
130
|
var result = {};
|
package/dist/future.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use `getConstraints` instead.
|
|
3
|
+
*/
|
|
1
4
|
export { getValibotConstraint } from './constraint';
|
|
2
5
|
export { coerceFormValue } from './coercion';
|
|
3
6
|
export { formatResult } from './format';
|
|
7
|
+
export { isSchema, getConstraints } from './schema';
|
|
4
8
|
//# sourceMappingURL=future.d.ts.map
|
package/dist/future.js
CHANGED
|
@@ -5,9 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var constraint = require('./constraint.js');
|
|
6
6
|
var coercion = require('./coercion.js');
|
|
7
7
|
var format = require('./format.js');
|
|
8
|
+
var schema = require('./schema.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
exports.getValibotConstraint = constraint.getValibotConstraint;
|
|
12
13
|
exports.coerceFormValue = coercion.coerceFormValue;
|
|
13
14
|
exports.formatResult = format.formatResult;
|
|
15
|
+
exports.getConstraints = schema.getConstraints;
|
|
16
|
+
exports.isSchema = schema.isSchema;
|
package/dist/future.mjs
CHANGED
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GenericSchema, GenericSchemaAsync } from 'valibot';
|
|
2
|
+
import type { ValidationAttributes } from '@conform-to/dom/future';
|
|
3
|
+
import { getValibotConstraint } from './constraint';
|
|
4
|
+
type ValibotSchema = GenericSchema | GenericSchemaAsync;
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if a value is a Valibot schema.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSchema(schema: unknown): schema is ValibotSchema;
|
|
9
|
+
/**
|
|
10
|
+
* Extracts HTML validation attributes from a Valibot schema.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getConstraints(schema: unknown): Record<string, ValidationAttributes> | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `getConstraints` instead.
|
|
15
|
+
*/
|
|
16
|
+
export { getValibotConstraint };
|
|
17
|
+
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var constraint = require('./constraint.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is a Valibot schema.
|
|
9
|
+
*/
|
|
10
|
+
function isSchema(schema) {
|
|
11
|
+
return typeof schema === 'object' && schema !== null && '~standard' in schema && typeof schema['~standard'] === 'object' && schema['~standard'] !== null && 'vendor' in schema['~standard'] && schema['~standard'].vendor === 'valibot';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Extracts HTML validation attributes from a Valibot schema.
|
|
16
|
+
*/
|
|
17
|
+
function getConstraints(schema) {
|
|
18
|
+
if (!isSchema(schema)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return constraint.getValibotConstraint(schema);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.getValibotConstraint = constraint.getValibotConstraint;
|
|
25
|
+
exports.getConstraints = getConstraints;
|
|
26
|
+
exports.isSchema = isSchema;
|
package/dist/schema.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getValibotConstraint } from './constraint.mjs';
|
|
2
|
+
export { getValibotConstraint } from './constraint.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to check if a value is a Valibot schema.
|
|
6
|
+
*/
|
|
7
|
+
function isSchema(schema) {
|
|
8
|
+
return typeof schema === 'object' && schema !== null && '~standard' in schema && typeof schema['~standard'] === 'object' && schema['~standard'] !== null && 'vendor' in schema['~standard'] && schema['~standard'].vendor === 'valibot';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Extracts HTML validation attributes from a Valibot schema.
|
|
13
|
+
*/
|
|
14
|
+
function getConstraints(schema) {
|
|
15
|
+
if (!isSchema(schema)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return getValibotConstraint(schema);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { getConstraints, isSchema };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Conform helpers for integrating with Valibot",
|
|
4
4
|
"homepage": "https://conform.guide",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.17.0",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"url": "https://github.com/edmundhung/conform/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@conform-to/dom": "1.
|
|
39
|
+
"@conform-to/dom": "1.17.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"valibot": ">= 0.32.0"
|