Skip to content
Source
Sign inSign up
TanStack/form

[v2] Allow validators to define custom data #2426

MergedLeCarbonator(GitHub profile, opens in a new tab)merged 5 commits intoalpha fromrefs/pull/2426/headmerged by LeCarbonator(GitHub profile, opens in a new tab)

Showing 47 changed files with 34 additions and 13 deletions (loading 44).

x
0 of 47 viewed, 47 left
21 additions and 0 deletions.changeset/grumpy-seals-dig.mdAdded
View file
@@ -0,0 +1,21 @@
+---
+'@tanstack/angular-form': minor
+'@tanstack/form-core': minor
+'@tanstack/preact-form': minor
+'@tanstack/react-form': minor
+---
+​
+BREAKING: `schemaOutputs` no longer exists. It is superceded by `validatorOutputs`. This is only a name change, the schema's result is the same as before
+​
+`validatorOutputs` now allows a callback validator to specify data that the submit function should know. Schemas do this
+automatically, but now you can do it manually as well:
+`run: ({ createOutput }) => createOutput('This is not a validation error and onSubmit can use this')`
+​
+The current map is:
+​
+| Validator | `onSubmit: ({ validatorOutputs }) => ...` |
+| -------------------------- | ----------------------------------------- |
+| Schema | Schema's output data |
+| `createOutput(X)` | `X` |
+| Default callback validator | `undefined` |
+| Validation error | N/A, `onSubmit` doesn't run |
9 additions and 9 deletions_artifacts/domain_map.yamlModified
View file
@@ -44,7 +44,7 @@
properties:
- 'defaultValues must align with the schema input type and should produce type errors when they do not.'
- 'Callbacks may not have useful inference unless a schema is present in the validator array.'
- - 'onSubmit should read the transform output from schemaOutputs instead of raw value.'
+ - 'onSubmit should read the transform output from validatorOutputs instead of raw value.'