Skip to content

Commit

Permalink
test: verify zod validator returns ValidationError[]
Browse files Browse the repository at this point in the history
refs #942
  • Loading branch information
Pascalmh committed Sep 6, 2024
1 parent 64fefaa commit b4d57fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/zod-form-adapter/tests/FormApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ describe('zod form api', () => {
form,
name: 'name',
validators: {
onChange: z.string().min(3, 'You must have a length of at least 3'),
onChange: z
.string()
.min(3, 'You must have a length of at least 3')
.regex(/^[a-z]+$/i, 'You must have only letters'),
},
})

field.mount()

expect(field.getMeta().errors).toEqual([])
field.setValue('a')
field.setValue('#') // too short and invalid character
expect(field.getMeta().errors).toEqual([
'You must have a length of at least 3',
'You must have only letters',
])
field.setValue('asdf')
expect(field.getMeta().errors).toEqual([])
Expand Down

0 comments on commit b4d57fa

Please sign in to comment.