Closed nfroidure closed 3 years ago
For AJV, this works:
const AJV = require('ajv');
const schema = {
type: 'object',
required: ['id', 'childs'],
additionalProperties: false,
properties: {
id: { type: 'string' },
childs: {
type: 'array',
items: { $ref: '#' },
},
},
};
var ajv = new AJV();
const valid = ajv.validate(schema, {
id: '1',
childs: [
{
id: 'id',
childs: [],
},
],
});
if (!valid) console.log(ajv.errors);
Looks like recursive schemas are leading to errors, here are a few things to check :