Skip to content

Commit

Permalink
feat: drop array items type checking (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-tymoshenko authored and jsumners committed Jun 21, 2024
1 parent 2c99bd1 commit 444ffa7
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions test/array.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,6 @@ buildTest({
'@data': ['test']
})

test('invalid items throw', (t) => {
t.plan(1)
const schema = {
type: 'object',
properties: {
args: {
type: 'array',
items: [
{
type: 'object',
patternProperties: {
'.*': {
type: 'string'
}
}
}
]
}
}
}
const stringify = build(schema)
t.throws(() => stringify({ args: ['invalid'] }))
})

buildTest({
title: 'item types in array default to any',
type: 'object',
Expand Down Expand Up @@ -329,8 +305,8 @@ test('array items is a list of schema and additionalItems is false /2', (t) => {

const stringify = build(schema)

t.throws(() => stringify({ foo: [1, 'bar'] }), new Error('Item at 0 does not match schema definition.'))
t.throws(() => stringify({ foo: ['foo', 1] }), new Error('Item at 1 does not match schema definition.'))
t.strictSame(stringify({ foo: [1, 'bar'] }), '{"foo":["1","bar"]}')
t.strictSame(stringify({ foo: ['foo', 1] }), '{"foo":["foo","1"]}')
t.throws(() => stringify({ foo: ['foo', 'bar', 'baz'] }), new Error('Item at 2 does not match schema definition.'))
})

Expand Down

0 comments on commit 444ffa7

Please sign in to comment.