tv4 icon indicating copy to clipboard operation
tv4 copied to clipboard

no name of the `additionalProperty` in the error message

Open drom opened this issue 9 years ago • 2 comments

For the following data / schema / code:

var data = {
    expected: 5,
    unexpected: 'foo'
};

var schema = {
    type: 'object',
    properties: {
        expected: {}
    },
    additionalProperties: false
};

var res = tv4.validateMultiple(data, schema);
console.log(JSON.stringify(res, null, 4));

The error message I am getting shows the dataPath but don't show the additional property name.

{
    "errors": [
        {
            "message": "Additional properties not allowed",
            "params": {},
            "code": 303,
            "dataPath": "",
            "schemaPath": "/additionalProperties",
            "subErrors": null,
            "stack": "Error\n    at new ValidationError ..."
        }
    ],
    "missing": [],
    "valid": false
}

I would expect to see my property name unexpected somewhere inside the error message or as a part of res.errors[0].dataPath.

drom avatar Aug 26 '15 19:08 drom

I'd like to plus one this issue. The change occurred between 1.2.0 and 1.2.1

sdizier avatar Sep 01 '15 18:09 sdizier

Sorry about this - should be fixed in 1.2.5.

geraintluff avatar Sep 02 '15 13:09 geraintluff