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

"dependencies" keyword prevents errors #45

Open
ozum opened this issue Jan 10, 2015 · 0 comments
Open

"dependencies" keyword prevents errors #45

ozum opened this issue Jan 10, 2015 · 0 comments

Comments

@ozum
Copy link

ozum commented Jan 10, 2015

If there is an error in dependencies, normal errors do not appear in errors object. See example below:

var schema = {
    "type": "object",

    "properties": {
        "name": { "type": "string" },
        "surname": { "type": "string" },
        "credit_card": { "type": "number" }
    },
    "dependencies": {
        "credit_card": {
            "properties": {
                "billing_address": { "type": "string" }
            },
            "required": ["billing_address"]
        }
    },
    "required": ["name", "surname"]
};

var data = {
    "credit_card": "jj"
};

var errors  = validator.validate(schema, data);

The errors object produced is:

{
    "validation": {
        "billing_address": {
            "required": true
        }
    }
}

However errors object should report name, surname fields should be required, and credit card field should be numeric.

Same schema produces with data below.

var data = {
    "age": 28
}

{
    "validation": {
        "name": {
            "required": true
        },
        "surname": {
            "required": true
        }
    }
}

Not to clutter here, I didn't include custom checks. Custom checks have same issue.

Regards,

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