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

Come up with a better alternative to the "not" : { "items" : { "not" pattern #4

Open
sahava opened this issue Jan 23, 2017 · 0 comments

Comments

@sahava
Copy link
Owner

sahava commented Jan 23, 2017

Currently the only way (I have found) to test if an array (window.dataLayer) simply contains an object is to use the

"type" : "array
"not" : {
    "items" : {
        "not" : {
            "type" : "object",
            "properties" : ...

pattern as used in /lib/testUtils.js. However, this is not only really ugly, but it also lacks proper validation error messages. If the test fails, the only thing the reporter knows is that the spec validated against a "not" condition. The reporter doesn't know what part of the spec failed. That's why there's the "FAILED ON: " workaround, where I expose the object on which the test failed in the error message.

As far as I know, there's not much to do about this yet. There's the "contains" keyword coming up (hopefully) in a future JSON Schema draft, but even then I'm not certain if it's descriptive enough.

So we need to figure out how to properly do an "array contains..." so that the validation error is still expressive enough to be informative.

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

1 participant