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

property name lost in validation message

Open bubenshchykov opened this issue 12 years ago • 0 comments

If I have allowAdditionalProperties: false, I always have validation message with empty property name

{
    "property": "",
    "message": "stringThe property categoryName is not defined in the schema and the schema does not allow additional properties"
}

Something is wrong with a "path" in validate.js line 122, I fixed it by

var actualPath = path ? path + "." + i : i;
errors.push({property:actualPath,message:(typeof value) + " property "  ...

and it looks nice after, and also works for nested properties

{
    "property": "categoryName",
    "message": "string property categoryName is not defined in the schema and the schema does not allow additional properties"
}

Not sure if the fix is correct, but could you pls take a look?

bubenshchykov avatar Apr 10 '13 09:04 bubenshchykov