json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

Why this example of referencing schema inside same object does not work?

Open ghost opened this issue 12 years ago • 0 comments

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

ghost avatar Jan 07 '13 13:01 ghost