We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c392c61 commit 5f2935cCopy full SHA for 5f2935c
packages/form-core/src/tests/FieldApi.spec.ts
@@ -140,4 +140,30 @@ describe('field api', () => {
140
141
expect(subfield.getValue()).toBe('one')
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
169
0 commit comments