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

undefined passes enum test #111

Open
Anahkiasen opened this issue Apr 7, 2016 · 2 comments
Open

undefined passes enum test #111

Anahkiasen opened this issue Apr 7, 2016 · 2 comments

Comments

@Anahkiasen
Copy link

I have this:

revalidator.validate({foo: undefined}, {
    properties: {
        foo: {
            enum: ['foo', 'bar'],
            type: 'string',
        },
    },
});

Which doesn't generate any error, surely undefined is not ['foo', 'bar'] nor is it a string, shouldn't this throw an error?

@cwp
Copy link

cwp commented Apr 15, 2016

Only if you have required: true in the schema for foo.

@Anahkiasen
Copy link
Author

Anahkiasen commented Apr 15, 2016

I tried with required but IIRC it passed as well, I had to convert the rule to a pattern: '(foo|bar)' currently. Will double check.

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