@fastify/merge-json-schemas
Version:
Builds a logical conjunction (AND) of multiple JSON schemas
30 lines (26 loc) • 619 B
JavaScript
const assert = require('node:assert/strict')
const { test } = require('node:test')
const { mergeSchemas } = require('../index')
const { defaultResolver } = require('./utils')
test('should merge two "not" keyword schemas', () => {
const schema1 = {
type: 'array',
not: {
type: 'string'
}
}
const schema2 = {
type: 'array',
not: {
type: 'string', minLength: 1
}
}
const mergedSchema = mergeSchemas([schema1, schema2], { defaultResolver })
assert.deepStrictEqual(mergedSchema, {
type: 'array',
not: {
type: 'string', minLength: 1
}
})
})