json-schema
json-schema copied to clipboard
Why this example of referencing schema inside same object does not work?
sch = {
type: 'object',
"properties": {
"str1": {
"type": "string",
"id": "#strref"
},
"str2": {
$ref: '#strref'
}
}
};
obj = {
str1: 'sss',
str2: 21
};
schema = require('json-schema');
console.dir(schema.validate(obj, sch));
Returns { valid: true, errors: [] }. But str2 isn't string