Skip to content

Regression on ref to empty schema crashes JSCK #97

@cxreg

Description

@cxreg

Starting in 0.2.8 this throws a fatal error. It only appears to happen if you have a reference to an empty schema. An empty schema by itself is fine as are refs in other situations.

var jsck = require("jsck").draft4;
var validator = new jsck({
    "type": "object",
    "properties": { "foo": { "$ref": "#/definitions/foo" } },
    "definitions": { "foo": {} }
});
var res = validator.validate({ "foo": "bar" });

I get this error

count@bumba:~/jsck-test$ ./crash-0.3.0.js

/home/count/jsck-test/node_modules/jsck/lib/validator.js:316
return (_ref1 = _this.uris[uri])._test.apply(_ref1, args);
^
TypeError: Cannot call method 'apply' of undefined
at /home/count/jsck-test/node_modules/jsck/lib/validator.js:316:54
at /home/count/jsck-test/node_modules/jsck/lib/draft4/objects.js:52:15
at Object.test_function as _test
at Object.validate (/home/count/jsck-test/node_modules/jsck/lib/validator.js:109:22)
at Validator.validate (/home/count/jsck-test/node_modules/jsck/lib/validator.js:94:34)
at Object. (/home/count/jsck-test/crash-0.3.0.js:11:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions