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

Combining oneOf + enum causes the rejection of enum fields #52

Open
iliocatallo opened this issue May 7, 2015 · 0 comments
Open

Combining oneOf + enum causes the rejection of enum fields #52

iliocatallo opened this issue May 7, 2015 · 0 comments

Comments

@iliocatallo
Copy link

Hi,

Given the following schema:

var schema  = {
    'type': 'object',
    'properties': { 
        'foo': { 
            'oneOf': [
                {
                    'type': 'integer'
                }, 
                {
                    'type': {'enum': ['bar', 'baz']}
                }
            ]
        }
    },
    'additionalProperties': false
};

The following does not work as I would expect:

js.validate({foo: 'bar'}, schema);

More precisely, the error reads:

js.validate({foo: 'bar'}, schema)[0].subSchemaValidationErrors
{ 'sub-schema-1': 
   [ { [Error]
       instanceContext: '#/foo',
       resolutionScope: 'anon-schema://e4d7cffef264084baaaceaa96437195d3e63275c/#/properties/foo/oneOf/0',
       constraintName: 'type',
       constraintValue: 'integer',
       testedValue: 'string' } ],
  'sub-schema-2': 
   [ { [Error]
       instanceContext: '#/foo',
       resolutionScope: 'anon-schema://e4d7cffef264084baaaceaa96437195d3e63275c/#/properties/foo/oneOf/1',
       constraintName: 'type',
       constraintValue: [Object],
       testedValue: 'string' } ] }

Apparently, the foo property is wrongly recognized as a string instead of one of the possible enum values.

Thanks.

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