@tanstack/form-core
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -89,6 +89,5 @@ import { | ||
const errorMapKey = getErrorMapKey(cause); | ||
if (error && this.state.meta.errorMap[errorMapKey] !== error) { | ||
if (this.state.meta.errorMap[errorMapKey] !== error) { | ||
this.setMeta((prev) => ({ | ||
...prev, | ||
errors: [...prev.errors, error], | ||
errorMap: { | ||
@@ -152,3 +151,2 @@ ...prev.errorMap, | ||
isValidating: false, | ||
errors: [...prev.errors, error], | ||
errorMap: { | ||
@@ -217,2 +215,5 @@ ...prev.errorMap, | ||
const state = this.store.state; | ||
state.meta.errors = Object.values(state.meta.errorMap).filter( | ||
(val) => val !== void 0 | ||
); | ||
state.meta.touchedErrors = state.meta.isTouched ? state.meta.errors : []; | ||
@@ -219,0 +220,0 @@ this.prevState = state; |
@@ -81,6 +81,5 @@ // src/FieldApi.ts | ||
const errorMapKey = getErrorMapKey(cause); | ||
if (error && this.state.meta.errorMap[errorMapKey] !== error) { | ||
if (this.state.meta.errorMap[errorMapKey] !== error) { | ||
this.setMeta((prev) => ({ | ||
...prev, | ||
errors: [...prev.errors, error], | ||
errorMap: { | ||
@@ -143,3 +142,2 @@ ...prev.errorMap, | ||
isValidating: false, | ||
errors: [...prev.errors, error], | ||
errorMap: { | ||
@@ -208,2 +206,5 @@ ...prev.errorMap, | ||
const state = this.store.state; | ||
state.meta.errors = Object.values(state.meta.errorMap).filter( | ||
(val) => val !== void 0 | ||
); | ||
state.meta.touchedErrors = state.meta.isTouched ? state.meta.errors : []; | ||
@@ -210,0 +211,0 @@ this.prevState = state; |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -143,2 +143,6 @@ import { type DeepKeys, type DeepValue, type Updater } from './utils' | ||
state.meta.errors = Object.values(state.meta.errorMap).filter( | ||
(val: unknown) => val !== undefined, | ||
) | ||
state.meta.touchedErrors = state.meta.isTouched | ||
@@ -272,6 +276,5 @@ ? state.meta.errors | ||
const errorMapKey = getErrorMapKey(cause) | ||
if (error && this.state.meta.errorMap[errorMapKey] !== error) { | ||
if (this.state.meta.errorMap[errorMapKey] !== error) { | ||
this.setMeta((prev) => ({ | ||
...prev, | ||
errors: [...prev.errors, error], | ||
errorMap: { | ||
@@ -363,3 +366,2 @@ ...prev.errorMap, | ||
isValidating: false, | ||
errors: [...prev.errors, error], | ||
errorMap: { | ||
@@ -366,0 +368,0 @@ ...prev.errorMap, |
@@ -504,2 +504,32 @@ import { expect } from 'vitest' | ||
it('should reset onChange errors when the issue is resolved', () => { | ||
const form = new FormApi({ | ||
defaultValues: { | ||
name: 'other', | ||
}, | ||
}) | ||
const field = new FieldApi({ | ||
form, | ||
name: 'name', | ||
onChange: (value) => { | ||
if (value === 'other') return 'Please enter a different value' | ||
return | ||
}, | ||
}) | ||
field.mount() | ||
field.setValue('other', { touch: true }) | ||
expect(field.getMeta().errors).toStrictEqual([ | ||
'Please enter a different value', | ||
]) | ||
expect(field.getMeta().errorMap).toEqual({ | ||
onChange: 'Please enter a different value', | ||
}) | ||
field.setValue('test', { touch: true }) | ||
expect(field.getMeta().errors).toStrictEqual([]) | ||
expect(field.getMeta().errorMap).toEqual({}) | ||
}) | ||
it('should handle default value on field using state.value', async () => { | ||
@@ -506,0 +536,0 @@ interface Form { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
343664
4460