const Ajv = require('ajv');
const ajv = new Ajv({useDefaults: true});
const schema ={
properties: {
foo: {
default: 'bar',
$ref: '#/definitions/foo'
// or, if you're a $ref purist:
// allOf: [{$ref: '#/definitions/foo'}]
}
},
definitions: {
foo: {
type: 'string'
}
}
};
let data = {};
ajv.validate(schema, data);
console.log(data);