Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
fix: add numbers[] to PlainObject, close #267
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jun 24, 2019
1 parent a01cfce commit ef22069
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type PlainObject = {
| null
| undefined
| string[]
| number[]
| PlainObject
| PlainObject[]
}
Expand Down
26 changes: 26 additions & 0 deletions test/numbers-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import test from 'ava'
import { assertBySchema, JsonSchema, PlainObject } from '..'

test('allows arrays of numbers', t => {
t.plan(0)
const jsonSchema: JsonSchema = {
title: 'Schema with numbers',
type: 'object',
additionalProperties: false,
properties: {
numbers: {
type: 'array',
items: {
type: 'number',
},
},
},
}
const example: PlainObject = {
numbers: [1, 2, 3],
}
const o: PlainObject = {
numbers: [101, 102, 103],
}
assertBySchema(jsonSchema, example)(o)
})

0 comments on commit ef22069

Please sign in to comment.