Skip to content

Commit

Permalink
test: add test validating that enums can be nullable and null
Browse files Browse the repository at this point in the history
Closes: #70
  • Loading branch information
thetutlage committed Nov 29, 2024
1 parent fe61951 commit 17a38d5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/integration/schema/enum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ test.group('Enum', () => {
role: 'admin',
})
})

test('allow enum to be nullable', async ({ assert }) => {
const schema = vine.object({
role: vine.enum(['admin', 'moderator', 'owner', 'user']).nullable(),
})

const data = {
role: null,
}

await assert.validationOutput(vine.validate({ schema, data }), {
role: null,
})
})
})

test.group('Enum | Native enum', () => {
Expand Down

0 comments on commit 17a38d5

Please sign in to comment.