natesilva / jayschema

[Unmaintained] - A comprehensive JSON Schema validator for Node.js
BSD 3-Clause "New" or "Revised" License
217 stars 22 forks source link

error: Undefined should be an object #54

Open alandotcom opened 9 years ago

alandotcom commented 9 years ago
var schema = {
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Result",
  "type": "object",
  "properties": {
    "additional_info": {
      "description": "More info",
      "type": "object",
    }
  },
  "additionalProperties": false
}

var instance = {additional_info: undefined};

var JaySchema = require('jayschema');
var js = new JaySchema();

js.validate(instance, schema, function(errs) {
  if (errs) { console.error(errs); }
  else { console.log('validation OK!'); }
});

/*
 * [ { [Error]
 *     instanceContext: '#/additional_info',
 *     resolutionScope: 'anon-schema://8acc7aec06a4b148e96a2130384cea97b268413d/#/properties/additional_info',
 *     constraintName: 'type',
 *     constraintValue: 'object',
 *     testedValue: 'undefined' } ]
 */