@tanstack/form-core 0.0.12 → 0.0.13

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.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Powerful, type-safe, framework agnostic forms.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -140,4 +140,30 @@ describe('field api', () => {
140
140
 
141
141
  expect(subfield.getValue()).toBe('one')
142
142
  })
143
+
144
+ it('should run validation onChange', async () => {
145
+ const form = new FormApi({
146
+ defaultValues: {
147
+ name: 'test',
148
+ },
149
+ })
150
+
151
+ const field = new FieldApi({
152
+ form,
153
+ name: 'name',
154
+ onChange: (value) => {
155
+ if (value === 'other') {
156
+ return 'Please enter a different value'
157
+ }
158
+
159
+ return
160
+ },
161
+ })
162
+
163
+ field.mount()
164
+
165
+ expect(field.getMeta().error).toBeUndefined()
166
+ field.setValue('other', { touch: true })
167
+ expect(field.getMeta().error).toBe('Please enter a different value')
168
+ })
143
169
  })