Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message: 'referenced schema does not match', #114

Open
ainthek opened this issue Apr 12, 2016 · 1 comment
Open

message: 'referenced schema does not match', #114

ainthek opened this issue Apr 12, 2016 · 1 comment

Comments

@ainthek
Copy link

ainthek commented Apr 12, 2016

normal and ref schemas return different messages.
I would expect messages to be same, indefepndent f I use ref or not.

{ field: 'data.a', message: 'is the wrong type' }
[ { field: 'data.a', message: 'referenced schema does not match' } ](too vague, BUGGy ? why not the same)

see code, I have tested also on ref.json in tests, with the same results (vague messages returned)

// comparing error messages from normal an ref schema
var validator = require("is-my-json-valid");
var validate = validator({
properties: {
a: {
type: 'integer'
}
},
"required": ["a"]
});

    validate({ a: 'string' });
    console.log(validate.errors);
    assert.deepEqual(validate.errors, [{ field: 'data.a', message: 'is the wrong type' }]);
    //now lets do the same with $ref
    var validate = validator({
        properties: {
            a: { $ref: "#/definitions/a" }
        },
        "required": ["a"],
        definitions: {
            a: {
                type: 'integer'
            }
        }

    });

    validate({ a: 'string' });
    console.log(validate.errors);
    assert.deepEqual(validate.errors, [{ field: 'data.a', message: 'is the wrong type' }]);
@emilbayes
Copy link
Collaborator

emilbayes commented May 20, 2016

This was changed in 2.0.2. I don't know what the reasoning was

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants