@conform-to/valibot 1.9.0 → 1.10.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 CHANGED
@@ -7,23 +7,23 @@
7
7
  ╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
8
8
  ```
9
9
 
10
- Version 1.9.0 / License MIT / Copyright (c) 2024 Edmund Hung
10
+ Version 1.10.0 / License MIT / Copyright (c) 2025 Edmund Hung
11
11
 
12
- A type-safe form validation library utilizing web fundamentals to progressively enhance HTML Forms with full support for server frameworks like Remix and Next.js.
12
+ Progressively enhance HTML forms with React. Build resilient, type-safe forms with no hassle using web standards.
13
13
 
14
- # Getting Started
14
+ ## Getting Started
15
15
 
16
16
  Check out the overview and tutorial at our website https://conform.guide
17
17
 
18
- # Features
18
+ ## Features
19
19
 
20
- - Progressive enhancement first APIs
21
- - Type-safe field inference
22
- - Fine-grained subscription
23
- - Built-in accessibility helpers
24
- - Automatic type coercion with Zod
20
+ - Full type safety with schema field inference
21
+ - Standard Schema support with enhanced Zod and Valibot integration
22
+ - Progressive enhancement first design with built-in accessibility features
23
+ - Native Server Actions support for Remix and Next.js
24
+ - Built on web standards for flexible composition with other tools
25
25
 
26
- # Documentation
26
+ ## Documentation
27
27
 
28
28
  - Validation: https://conform.guide/validation
29
29
  - Nested object and Array: https://conform.guide/complex-structures
@@ -31,6 +31,6 @@ Check out the overview and tutorial at our website https://conform.guide
31
31
  - Intent button: https://conform.guide/intent-button
32
32
  - Accessibility Guide: https://conform.guide/accessibility
33
33
 
34
- # Support
34
+ ## Support
35
35
 
36
36
  To report a bug, please open an issue on the repository at https://github.com/edmundhung/conform. For feature requests and questions, you can post them in the Discussions section.
@@ -37,6 +37,33 @@ function _defineProperty(obj, key, value) {
37
37
  }
38
38
  return obj;
39
39
  }
40
+ function _objectWithoutPropertiesLoose(source, excluded) {
41
+ if (source == null) return {};
42
+ var target = {};
43
+ var sourceKeys = Object.keys(source);
44
+ var key, i;
45
+ for (i = 0; i < sourceKeys.length; i++) {
46
+ key = sourceKeys[i];
47
+ if (excluded.indexOf(key) >= 0) continue;
48
+ target[key] = source[key];
49
+ }
50
+ return target;
51
+ }
52
+ function _objectWithoutProperties(source, excluded) {
53
+ if (source == null) return {};
54
+ var target = _objectWithoutPropertiesLoose(source, excluded);
55
+ var key, i;
56
+ if (Object.getOwnPropertySymbols) {
57
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
58
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
59
+ key = sourceSymbolKeys[i];
60
+ if (excluded.indexOf(key) >= 0) continue;
61
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
62
+ target[key] = source[key];
63
+ }
64
+ }
65
+ return target;
66
+ }
40
67
  function _toPrimitive(input, hint) {
41
68
  if (typeof input !== "object" || input === null) return input;
42
69
  var prim = input[Symbol.toPrimitive];
@@ -54,5 +81,7 @@ function _toPropertyKey(arg) {
54
81
 
55
82
  exports.defineProperty = _defineProperty;
56
83
  exports.objectSpread2 = _objectSpread2;
84
+ exports.objectWithoutProperties = _objectWithoutProperties;
85
+ exports.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
57
86
  exports.toPrimitive = _toPrimitive;
58
87
  exports.toPropertyKey = _toPropertyKey;
@@ -33,6 +33,33 @@ function _defineProperty(obj, key, value) {
33
33
  }
34
34
  return obj;
35
35
  }
36
+ function _objectWithoutPropertiesLoose(source, excluded) {
37
+ if (source == null) return {};
38
+ var target = {};
39
+ var sourceKeys = Object.keys(source);
40
+ var key, i;
41
+ for (i = 0; i < sourceKeys.length; i++) {
42
+ key = sourceKeys[i];
43
+ if (excluded.indexOf(key) >= 0) continue;
44
+ target[key] = source[key];
45
+ }
46
+ return target;
47
+ }
48
+ function _objectWithoutProperties(source, excluded) {
49
+ if (source == null) return {};
50
+ var target = _objectWithoutPropertiesLoose(source, excluded);
51
+ var key, i;
52
+ if (Object.getOwnPropertySymbols) {
53
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
54
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
55
+ key = sourceSymbolKeys[i];
56
+ if (excluded.indexOf(key) >= 0) continue;
57
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
58
+ target[key] = source[key];
59
+ }
60
+ }
61
+ return target;
62
+ }
36
63
  function _toPrimitive(input, hint) {
37
64
  if (typeof input !== "object" || input === null) return input;
38
65
  var prim = input[Symbol.toPrimitive];
@@ -48,4 +75,4 @@ function _toPropertyKey(arg) {
48
75
  return typeof key === "symbol" ? key : String(key);
49
76
  }
50
77
 
51
- export { _defineProperty as defineProperty, _objectSpread2 as objectSpread2, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey };
78
+ export { _defineProperty as defineProperty, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey };
@@ -0,0 +1,24 @@
1
+ import type { GenericSchema, GenericSchemaAsync, InferIssue, InferOutput, SafeParseResult } from 'valibot';
2
+ import { type FormError } from '@conform-to/dom/future';
3
+ export declare function formatResult<Schema extends GenericSchema | GenericSchemaAsync>(result: SafeParseResult<Schema>): FormError<string> | null;
4
+ export declare function formatResult<Schema extends GenericSchema | GenericSchemaAsync, ErrorShape = string>(result: SafeParseResult<Schema>, options: {
5
+ /** Whether to include the parsed value in the returned object */
6
+ includeValue: true;
7
+ /** Custom function to format validation issues for each field */
8
+ formatIssues: (issues: InferIssue<Schema>[], name: string) => ErrorShape[];
9
+ }): {
10
+ error: FormError<ErrorShape> | null;
11
+ value: InferOutput<Schema> | undefined;
12
+ };
13
+ export declare function formatResult<Schema extends GenericSchema | GenericSchemaAsync>(result: SafeParseResult<Schema>, options: {
14
+ includeValue: true;
15
+ formatIssues?: undefined;
16
+ }): {
17
+ error: FormError<string> | null;
18
+ value: InferOutput<Schema> | undefined;
19
+ };
20
+ export declare function formatResult<Schema extends GenericSchema | GenericSchemaAsync, ErrorShape = string>(result: SafeParseResult<Schema>, options: {
21
+ includeValue?: false;
22
+ formatIssues: (issues: InferIssue<Schema>[], name: string) => ErrorShape[];
23
+ }): FormError<ErrorShape> | null;
24
+ //# sourceMappingURL=format.d.ts.map
package/dist/format.js ADDED
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
6
+ var future = require('@conform-to/dom/future');
7
+
8
+ var _excluded = [""];
9
+ function formatResult(result, options) {
10
+ var error = null;
11
+ if (!result.success) {
12
+ var errorByName = {};
13
+ for (var issue of result.issues) {
14
+ var _errorByName$_name;
15
+ if (!issue.path) {
16
+ var _ref, _errorByName$_ref;
17
+ (_errorByName$_ref = errorByName[_ref = '']) !== null && _errorByName$_ref !== void 0 ? _errorByName$_ref : errorByName[_ref] = [];
18
+ errorByName[''].push(issue);
19
+ continue;
20
+ }
21
+ var _name = issue.path.reduce((name, segment) => {
22
+ if (typeof segment.key !== 'string' && typeof segment.key !== 'number') {
23
+ throw new Error("Only string or numeric path segment schemes are supported. Received segment: ".concat(segment.key));
24
+ }
25
+ return future.appendPathSegment(name, segment.key);
26
+ }, '');
27
+ (_errorByName$_name = errorByName[_name]) !== null && _errorByName$_name !== void 0 ? _errorByName$_name : errorByName[_name] = [];
28
+ errorByName[_name].push(issue);
29
+ }
30
+ var _Object$entries$reduc = Object.entries(errorByName).reduce((result, _ref2) => {
31
+ var [name, issues] = _ref2;
32
+ result[name] = options !== null && options !== void 0 && options.formatIssues ? options.formatIssues(issues, name) : issues.map(issue => issue.message);
33
+ return result;
34
+ }, {}),
35
+ {
36
+ '': formErrors = []
37
+ } = _Object$entries$reduc,
38
+ fieldErrors = _rollupPluginBabelHelpers.objectWithoutProperties(_Object$entries$reduc, _excluded);
39
+ error = {
40
+ formErrors,
41
+ fieldErrors
42
+ };
43
+ }
44
+ if (options !== null && options !== void 0 && options.includeValue) {
45
+ return {
46
+ error,
47
+ value: result.success ? result.output : undefined
48
+ };
49
+ }
50
+ return error;
51
+ }
52
+
53
+ exports.formatResult = formatResult;
@@ -0,0 +1,49 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
+ import { appendPathSegment } from '@conform-to/dom/future';
3
+
4
+ var _excluded = [""];
5
+ function formatResult(result, options) {
6
+ var error = null;
7
+ if (!result.success) {
8
+ var errorByName = {};
9
+ for (var issue of result.issues) {
10
+ var _errorByName$_name;
11
+ if (!issue.path) {
12
+ var _ref, _errorByName$_ref;
13
+ (_errorByName$_ref = errorByName[_ref = '']) !== null && _errorByName$_ref !== void 0 ? _errorByName$_ref : errorByName[_ref] = [];
14
+ errorByName[''].push(issue);
15
+ continue;
16
+ }
17
+ var _name = issue.path.reduce((name, segment) => {
18
+ if (typeof segment.key !== 'string' && typeof segment.key !== 'number') {
19
+ throw new Error("Only string or numeric path segment schemes are supported. Received segment: ".concat(segment.key));
20
+ }
21
+ return appendPathSegment(name, segment.key);
22
+ }, '');
23
+ (_errorByName$_name = errorByName[_name]) !== null && _errorByName$_name !== void 0 ? _errorByName$_name : errorByName[_name] = [];
24
+ errorByName[_name].push(issue);
25
+ }
26
+ var _Object$entries$reduc = Object.entries(errorByName).reduce((result, _ref2) => {
27
+ var [name, issues] = _ref2;
28
+ result[name] = options !== null && options !== void 0 && options.formatIssues ? options.formatIssues(issues, name) : issues.map(issue => issue.message);
29
+ return result;
30
+ }, {}),
31
+ {
32
+ '': formErrors = []
33
+ } = _Object$entries$reduc,
34
+ fieldErrors = _objectWithoutProperties(_Object$entries$reduc, _excluded);
35
+ error = {
36
+ formErrors,
37
+ fieldErrors
38
+ };
39
+ }
40
+ if (options !== null && options !== void 0 && options.includeValue) {
41
+ return {
42
+ error,
43
+ value: result.success ? result.output : undefined
44
+ };
45
+ }
46
+ return error;
47
+ }
48
+
49
+ export { formatResult };
@@ -0,0 +1,4 @@
1
+ export { getValibotConstraint } from './constraint';
2
+ export { coerceFormValue } from './coercion';
3
+ export { formatResult } from './format';
4
+ //# sourceMappingURL=future.d.ts.map
package/dist/future.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var constraint = require('./constraint.js');
6
+ var coercion = require('./coercion.js');
7
+ var format = require('./format.js');
8
+
9
+
10
+
11
+ exports.getValibotConstraint = constraint.getValibotConstraint;
12
+ exports.coerceFormValue = coercion.coerceFormValue;
13
+ exports.formatResult = format.formatResult;
@@ -0,0 +1,3 @@
1
+ export { getValibotConstraint } from './constraint.mjs';
2
+ export { coerceFormValue } from './coercion.mjs';
3
+ export { formatResult } from './format.mjs';
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.9.0",
6
+ "version": "1.10.0",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
@@ -14,6 +14,13 @@
14
14
  "import": "./dist/index.mjs",
15
15
  "require": "./dist/index.js",
16
16
  "default": "./dist/index.mjs"
17
+ },
18
+ "./future": {
19
+ "types": "./dist/future.d.ts",
20
+ "module": "./dist/future.mjs",
21
+ "import": "./dist/future.mjs",
22
+ "require": "./dist/future.js",
23
+ "default": "./dist/future.mjs"
17
24
  }
18
25
  },
19
26
  "files": [
@@ -29,7 +36,7 @@
29
36
  "url": "https://github.com/edmundhung/conform/issues"
30
37
  },
31
38
  "dependencies": {
32
- "@conform-to/dom": "1.9.0"
39
+ "@conform-to/dom": "1.10.0"
33
40
  },
34
41
  "peerDependencies": {
35
42
  "valibot": ">= 0.32.0"