Skip to content

Commit 0bd9490

Browse files
ci: apply automated fixes and generate docs
1 parent 3c072c0 commit 0bd9490

1 file changed

Lines changed: 45 additions & 43 deletions

File tree

packages/form-core/tests/standardSchemaValidator.spec.ts

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -610,50 +610,52 @@ describe('standard schema validator', () => {
610610
})
611611

612612
it("should clean onMount errors when replacing an array field's value", () => {
613-
const schema = z.object({
614-
people: z.array(
615-
z.object({
616-
firstName: z.string().min(3),
617-
lastName: z.string().min(3),
618-
}),
619-
),
620-
})
621-
622-
const form = new FormApi({
623-
defaultValues: {
624-
people: [
625-
{
626-
firstName: '',
627-
lastName: '',
628-
},
629-
],
630-
},
631-
validators: {
632-
onMount: schema,
633-
onChange: schema,
634-
},
635-
})
636-
form.mount()
637-
638-
// Since validation runs through the field, a field must be mounted for that array
639-
new FieldApi({ form, name: 'people' }).mount()
640-
641-
form.replaceFieldValue('people', 0, {
642-
firstName: 'Chuck',
643-
lastName: 'Norris',
644-
})
645-
646-
expect(form.state.values).toStrictEqual({
613+
const schema = z.object({
614+
people: z.array(
615+
z.object({
616+
firstName: z.string().min(3),
617+
lastName: z.string().min(3),
618+
}),
619+
),
620+
})
621+
622+
const form = new FormApi({
623+
defaultValues: {
647624
people: [
648625
{
649-
firstName: 'Chuck',
650-
lastName: 'Norris',
651-
}
652-
]
653-
})
654-
expect(form.state.fieldMetaBase["people[0].firstName"]!.errorMap).toStrictEqual({})
655-
expect(
656-
form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap,
657-
).toStrictEqual({})
626+
firstName: '',
627+
lastName: '',
628+
},
629+
],
630+
},
631+
validators: {
632+
onMount: schema,
633+
onChange: schema,
634+
},
635+
})
636+
form.mount()
637+
638+
// Since validation runs through the field, a field must be mounted for that array
639+
new FieldApi({ form, name: 'people' }).mount()
640+
641+
form.replaceFieldValue('people', 0, {
642+
firstName: 'Chuck',
643+
lastName: 'Norris',
658644
})
645+
646+
expect(form.state.values).toStrictEqual({
647+
people: [
648+
{
649+
firstName: 'Chuck',
650+
lastName: 'Norris',
651+
},
652+
],
653+
})
654+
expect(
655+
form.state.fieldMetaBase['people[0].firstName']!.errorMap,
656+
).toStrictEqual({})
657+
expect(
658+
form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap,
659+
).toStrictEqual({})
660+
})
659661
})

0 commit comments

Comments
 (0)