@tanstack/form-core 0.40.0 → 0.40.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/form-core",
3
- "version": "0.40.0",
3
+ "version": "0.40.1",
4
4
  "description": "Powerful, type-safe, framework agnostic forms.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "@tanstack/store": "^0.6.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@standard-schema/spec": "1.0.0-beta.3",
43
+ "@standard-schema/spec": "1.0.0-beta.4",
44
44
  "arktype": "2.0.0-rc.23",
45
45
  "valibot": "^1.0.0-beta.9",
46
46
  "zod": "^3.24.0"
package/src/FieldApi.ts CHANGED
@@ -15,6 +15,7 @@ import type {
15
15
  } from './types'
16
16
  import type { AsyncValidator, SyncValidator, Updater } from './utils'
17
17
  import type { DeepKeys, DeepValue, NoInfer } from './util-types'
18
+ import type { StandardSchemaV1 } from '@standard-schema/spec'
18
19
 
19
20
  /**
20
21
  * @private
@@ -68,13 +69,15 @@ export type FieldValidateOrFn<
68
69
  TFormValidator,
69
70
  TData
70
71
  >
71
- : FieldValidateFn<
72
- TParentData,
73
- TName,
74
- TFieldValidator,
75
- TFormValidator,
76
- TData
77
- >
72
+ :
73
+ | FieldValidateFn<
74
+ TParentData,
75
+ TName,
76
+ TFieldValidator,
77
+ TFormValidator,
78
+ TData
79
+ >
80
+ | StandardSchemaV1
78
81
 
79
82
  /**
80
83
  * @private
@@ -129,13 +132,15 @@ export type FieldAsyncValidateOrFn<
129
132
  TFormValidator,
130
133
  TData
131
134
  >
132
- : FieldValidateAsyncFn<
133
- TParentData,
134
- TName,
135
- TFieldValidator,
136
- TFormValidator,
137
- TData
138
- >
135
+ :
136
+ | FieldValidateAsyncFn<
137
+ TParentData,
138
+ TName,
139
+ TFieldValidator,
140
+ TFormValidator,
141
+ TData
142
+ >
143
+ | StandardSchemaV1<TData, unknown>
139
144
 
140
145
  /**
141
146
  * @private
package/src/FormApi.ts CHANGED
@@ -26,7 +26,7 @@ import type {
26
26
  } from './types'
27
27
  import type { DeepKeys, DeepValue } from './util-types'
28
28
  import type { Updater } from './utils'
29
- import type { v1 } from '@standard-schema/spec'
29
+ import type { StandardSchemaV1 } from '@standard-schema/spec'
30
30
 
31
31
  export type FieldsErrorMapFromValidator<TFormData> = Partial<
32
32
  Record<DeepKeys<TFormData>, ValidationErrorMap>
@@ -51,7 +51,7 @@ export type FormValidateOrFn<
51
51
  ? TFN | FormValidateFn<TFormData, TFormValidator>
52
52
  :
53
53
  | FormValidateFn<TFormData, TFormValidator>
54
- | v1.StandardSchema<TFormData, unknown>
54
+ | StandardSchemaV1<TFormData, unknown>
55
55
 
56
56
  /**
57
57
  * @private
@@ -91,7 +91,7 @@ export type FormAsyncValidateOrFn<
91
91
  ? FFN | FormValidateAsyncFn<TFormData, TFormValidator>
92
92
  :
93
93
  | FormValidateAsyncFn<TFormData, TFormValidator>
94
- | v1.StandardSchema<TFormData, unknown>
94
+ | StandardSchemaV1<TFormData, unknown>
95
95
 
96
96
  export interface FormValidators<
97
97
  TFormData,
@@ -3,16 +3,16 @@ import type {
3
3
  Validator,
4
4
  ValidatorAdapterParams,
5
5
  } from './types'
6
- import type { v1 } from '@standard-schema/spec'
6
+ import type { StandardSchemaV1 } from '@standard-schema/spec'
7
7
 
8
- type Params = ValidatorAdapterParams<v1.StandardIssue>
8
+ type Params = ValidatorAdapterParams<StandardSchemaV1.Issue>
9
9
  type TransformFn = NonNullable<Params['transformErrors']>
10
10
 
11
11
  function prefixSchemaToErrors(
12
- issues: readonly v1.StandardIssue[],
12
+ issues: readonly StandardSchemaV1.Issue[],
13
13
  transformErrors: TransformFn,
14
14
  ) {
15
- const schema = new Map<string, v1.StandardIssue[]>()
15
+ const schema = new Map<string, StandardSchemaV1.Issue[]>()
16
16
 
17
17
  for (const issue of issues) {
18
18
  const path = [...(issue.path ?? [])]
@@ -39,18 +39,18 @@ function prefixSchemaToErrors(
39
39
  }
40
40
 
41
41
  function defaultFormTransformer(transformErrors: TransformFn) {
42
- return (issues: readonly v1.StandardIssue[]) => ({
43
- form: transformErrors(issues as v1.StandardIssue[]),
42
+ return (issues: readonly StandardSchemaV1.Issue[]) => ({
43
+ form: transformErrors(issues as StandardSchemaV1.Issue[]),
44
44
  fields: prefixSchemaToErrors(issues, transformErrors),
45
45
  })
46
46
  }
47
47
 
48
48
  export const standardSchemaValidator =
49
- (params: Params = {}): Validator<unknown, v1.StandardSchema<any, any>> =>
49
+ (params: Params = {}): Validator<unknown, StandardSchemaV1> =>
50
50
  () => {
51
51
  const transformFieldErrors =
52
52
  params.transformErrors ??
53
- ((issues: v1.StandardIssue[]) =>
53
+ ((issues: StandardSchemaV1.Issue[]) =>
54
54
  issues.map((issue) => issue.message).join(', '))
55
55
 
56
56
  const getTransformStrategy = (validationSource: 'form' | 'field') =>
@@ -70,7 +70,7 @@ export const standardSchemaValidator =
70
70
 
71
71
  const transformer = getTransformStrategy(validationSource)
72
72
 
73
- return transformer(result.issues as v1.StandardIssue[])
73
+ return transformer(result.issues as StandardSchemaV1.Issue[])
74
74
  },
75
75
  async validateAsync({ value, validationSource }, fn) {
76
76
  const result = await fn['~standard'].validate(value)
@@ -79,12 +79,12 @@ export const standardSchemaValidator =
79
79
 
80
80
  const transformer = getTransformStrategy(validationSource)
81
81
 
82
- return transformer(result.issues as v1.StandardIssue[])
82
+ return transformer(result.issues as StandardSchemaV1.Issue[])
83
83
  },
84
84
  }
85
85
  }
86
86
 
87
87
  export const isStandardSchemaValidator = (
88
88
  validator: unknown,
89
- ): validator is v1.StandardSchema =>
89
+ ): validator is StandardSchemaV1 =>
90
90
  !!validator && '~standard' in (validator as object)