-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Sample taken directly from the Readme, with an id added to the schema:
jsck = new JSCK.draft4
id: "http://www.google.com"
type: "object"
properties:
user:
type: "object"
required: ["login"]
properties:
login:
type: "string"
pattern: "^[\\w\\d_]{3,32}$"
email:
type: "string"
format: "email"
jsck.validate
user:
login: "matthew"
email: "matthew@pandastrike.com"This throws the error:
Error: No schema found for '"#"'
at Validator.validator (/Users/jasonkarns/Projects/shutterstock/analytics-schema/node_modules/jsck/lib/validator.js:142:15)
at Validator.validate (/Users/jasonkarns/Projects/shutterstock/analytics-schema/node_modules/jsck/lib/validator.js:99:19)
at repl:1:6
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
Based on my debugging, this occurs because a schema's id is used as the key for that schema. If no id is provided, then the schema is indexed with # as the key.
Lines 78 to 80 in fdc93ac
| context = new Context | |
| pointer: schema.id || "#" | |
| scope: schema.id || "#" |
Then when validation is attempted, the validate call just blindly uses '#' as the key to lookup the schema:
Line 86 in fdc93ac
| @validator("#").validate(data) |
If the schema in question has an id, then the schema lookup fails to find one indexed under '#', and throws the error:
Line 107 in fdc93ac
| throw new Error "No schema found for '#{JSON.stringify(arg)}'" |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels