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

allow_unknown inside *of rule is ignored #251

Closed
daviskirk opened this Issue Jul 28, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@daviskirk
Copy link
Contributor

daviskirk commented Jul 28, 2016

When trying to use allow_unknown within an *of clause, validation fails.
This is perhaps related to #250 , but as no exception is thrown in this case and the error tree is seemingly successfully built and only ignores the allow_unknown flag, I'm opening a separate issue.

# This is the schema that causes the problem
schema1 = {
    'test': {
        'oneof': [
            {
                'type': 'dict', 
                'allow_unknown':True, 
                'schema': {'a': {'type': 'string'}}
            }
        ]
    }
}

# This is a control schema, meaning it is the same as the above, 
# just without wrapping the `oneof` clause around the inner `'dict'`
schema2 = {
    'test': {
        'type': 'dict', 
        'allow_unknown':True, 
        'schema': {'a': {'type': 'string'}}
    }
}

v1 = cerberus.Validator(schema1) 
v1.validate({'test': {'a': 's'}}) #  returns True (as expected) 
v1.validate({'test': {'a': 's', 'b': 'asd'}}) #  returns False (is `allow_unknown` ignored?)
print(v1.errors) #  {'test': [{'oneof': ['none or more than one rule validate', {'oneof definition 0': ['unknown field']}]}]}

v2 = cerberus.Validator(schema2)  
v2.validate({'test': {'a': 's', 'b': 'asd'}}) #  returns True (as expected)

daviskirk added a commit to daviskirk/cerberus that referenced this issue Aug 26, 2016

Fixes pyeve#251
- add test
@daviskirk

This comment has been minimized.

Copy link
Contributor

daviskirk commented Aug 26, 2016

This has nothing to do with #250 as it turns out.

@nicolaiarocci nicolaiarocci added this to the 1.0 milestone Aug 29, 2016

@nicolaiarocci nicolaiarocci added the bug label Aug 29, 2016

nicolaiarocci added a commit that referenced this issue Aug 30, 2016

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Oct 26, 2016

Fixes pyeve#251
- add test

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Oct 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment