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

'ARRAY_ADDITIONAL_ITEMS' error unreachable? #259

Open
Ligengxin96 opened this issue Jun 12, 2020 · 0 comments
Open

'ARRAY_ADDITIONAL_ITEMS' error unreachable? #259

Ligengxin96 opened this issue Jun 12, 2020 · 0 comments

Comments

@Ligengxin96
Copy link

Ligengxin96 commented Jun 12, 2020

If Array.isArray(json) is true, it means schema.type must be an Array.
So, schema.items always is an Object.
If i was wrong, how should I define a shcame to make this error reachable?

(JsonValidation.js line 108)

 additionalItems: function (report, schema, json) {
        // http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.3.1.2
        if (shouldSkipValidate(this.validateOptions, ["ARRAY_ADDITIONAL_ITEMS"])) {
            return;
        }
        if (!Array.isArray(json)) {
            return;
        }
        // if the value of "additionalItems" is boolean value false and the value of "items" is an array,
        // the json is valid if its size is less than, or equal to, the size of "items".
        if (schema.additionalItems === false && Array.isArray(schema.items)) {
            if (json.length > schema.items.length) {
                report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema);
            }
        }
    }
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