Skip to content

Commit 711fd1f

Browse files
committed
Fix #2
1 parent 9b8647d commit 711fd1f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

example/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const initialValues: ExampleFormData = {
8585

8686
const TodoListSchema = yup.object({
8787
name: yup.string().required("Enter a name").min(5, "Enter a longer name"),
88+
language: yup.string().oneOf(["en", "nl"], "Must be english or dutch"),
8889
todos: yup.array().of(
8990
yup.object({
9091
message: yup.string().required("Enter a todo")
@@ -187,6 +188,7 @@ export function Form() {
187188
<option value="nl">Dutch</option>
188189
<option value="fr">French</option>
189190
</FormSelect>
191+
<FormError form={form} name="language" />
190192
<p>Using radio buttons</p>
191193
<label>
192194
<FormInput type="radio" form={form} name="language" value="en" /> English

src/form.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,16 @@ export class FormState<T, State = DefaultState, Error extends string = DefaultEr
353353
let changed = false;
354354
for (let i = keys.length; i >= 0; i--) {
355355
let key = keys[i] as keyof T;
356-
changed =
357-
changed ||
356+
if (
358357
this.setError(
359358
key,
360359
errors[key] as any,
361360
notifyChild,
362361
false, // Will call updateParentErrors by itself after all values have been copied, see 3 lines down
363362
false // Will call fireAnyListener by itself after all values have been copied, see 3 lines down
364-
);
363+
)
364+
)
365+
changed = true;
365366
}
366367
if (!changed) return false;
367368
this.fireAnyListeners();

0 commit comments

Comments
 (0)