Skip to content

Commit 5bb409e

Browse files
committed
setError readability change
1 parent 711fd1f commit 5bb409e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

example/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function ArrayTest() {
130130
export function Form() {
131131
const form = useForm(
132132
initialValues, // <- Default values, may change
133-
yupValidator(TodoListSchema), // <- Validator (optional)
133+
yupValidator(TodoListSchema, { abortEarly: false }), // <- Validator (optional)
134134
false, // <- Validate on change (optional)
135135
false // <- Validate on mount (optional)
136136
);

src/form.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,12 @@ export class FormState<T, State = DefaultState, Error extends string = DefaultEr
327327
else this.errorMap[key] = error;
328328

329329
if (notifyChild && this.childMap[key]) {
330-
let changed = !this.childMap[key]!.setErrors((typeof error === "object" ? error ?? {} : {}) as any, true, false);
331-
// Only return if the object changed, when a string error was given, this should not return
332-
if (changed && typeof error === "object") return false;
330+
if (typeof error === "object") {
331+
let changed = this.childMap[key]!.setErrors((error as any) ?? {}, true, false);
332+
if (!changed) return false;
333+
} else {
334+
this.childMap[key]!.setErrors({}, true, false);
335+
}
333336
}
334337

335338
this.fireListeners(key);

0 commit comments

Comments
 (0)