diff --git a/index.js b/index.js index 694f7843..efee5081 100644 --- a/index.js +++ b/index.js @@ -571,12 +571,8 @@ function buildArray (context, location) { ` } - if (largeArrayMechanism !== 'default') { - if (largeArrayMechanism === 'json-stringify') { - functionCode += `if (arrayLength && arrayLength >= ${largeArraySize}) return JSON.stringify(obj)\n` - } else { - throw new Error(`Unsupported large array mechanism ${largeArrayMechanism}`) - } + if (largeArrayMechanism === 'json-stringify') { + functionCode += `if (arrayLength && arrayLength >= ${largeArraySize}) return JSON.stringify(obj)\n` } functionCode += ` @@ -663,8 +659,6 @@ function buildArrayTypeCondition (type, accessor) { return buildArrayTypeCondition(subType, accessor) }) condition = `(${conditions.join(' || ')})` - } else { - throw new Error(`${type} unsupported`) } } return condition diff --git a/test/integer.test.js b/test/integer.test.js index 78ac9ac3..c4a2415a 100644 --- a/test/integer.test.js +++ b/test/integer.test.js @@ -35,6 +35,18 @@ test('render a float as an integer', (t) => { } }) +test('throws on NaN', (t) => { + t.plan(1) + + const schema = { + title: 'integer', + type: 'integer' + } + + const stringify = build(schema) + t.throws(() => stringify(NaN), new Error('The value "NaN" cannot be converted to an integer.')) +}) + test('render a float as an integer', (t) => { const cases = [ { input: Math.PI, output: '3' },