Skip to content

Commit

Permalink
add MixedSchema type test
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-ayf committed Jul 24, 2023
1 parent 95dfdf1 commit 72d5a54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions types/FluentJSONSchema.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ const bodySchema = personSchema.without(['createdAt', 'updatedAt'])

console.log('person subset:', JSON.stringify(bodySchema.valueOf()))

const personSchemaAllowsUnix = S.object()
.prop('name', S.string())
.prop('age', S.number())
.prop('id', S.string().format('uuid'))
.prop('createdAt', S.mixed(['string', 'integer']).format('time'))
.prop('updatedAt', S.mixed(['string', 'integer']).minimum(0))

console.log('person schema allows unix:', JSON.stringify(personSchemaAllowsUnix.valueOf()))

try {
S.object().prop('foo', 'boom!' as any)
} catch (e) {
Expand Down

0 comments on commit 72d5a54

Please sign in to comment.