fast-json-stringify
Version:
Stringify your JSON at max speed
20 lines (16 loc) • 476 B
JavaScript
const { test } = require('node:test')
const build = require('..')
test('should throw a TypeError with the path to the key of the invalid value', (t) => {
t.plan(1)
const schema = {
type: 'object',
properties: {
num: {
type: ['number']
}
}
}
const stringify = build(schema)
t.assert.throws(() => stringify({ num: { bla: 123 } }), new TypeError('The value of \'#/properties/num\' does not match schema definition.'))
})