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

validation throws error when validatin a schema that contain multiple types #70

Open
gabrieldodan opened this issue Apr 5, 2017 · 0 comments

Comments

@gabrieldodan
Copy link

Hi guys,
The below code throws error when data = null. Seems there is a bug on validation algorithm. Can be fixed? Also if I remove the "required" attribute then it works proper.

Regards!

var jjv = require('jjv')();


jjv.addSchema('user', {
    type: ["object", "null"],
    properties: {
        firstname: {
            type: 'string',
            minLength: 2,
            maxLength: 15
        },
        lastname: {
            type: 'string',
            minLength: 2,
            maxLength: 25
        },
        gender: {
            type: 'string',
            enum: ['male', 'female']
        },
        email: {
            type: 'string',
            format: 'email'
        },
        password: {
            type: 'string',
            minLength: 8
        }
    },
    required: ['firstname', 'lastname']
});


var errors = jjv.validate('user', null);
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