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

Deprecation of keyschema and valueschema does not work when in subschema #482

Closed
ningirsu opened this issue Apr 30, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@ningirsu
Copy link

commented Apr 30, 2019

Used Cerberus version 1.3

Bug report / Feature request

Depreciation of the rule keyschema and valueschema does not work properly when in a subschema of valueschema or keyschema on itself:

This snipet will not work for instance:

schema = {
    "a": {
        'type': 'dict',
        'valueschema': {
            'type': 'dict',
            'keyschema': {
                'type': 'string',
            },
            'valueschema': {
                'type': 'string'
            },
        }
    }
}
cerberus.Validator(schema)

Output will be:

(BackEnd)  moutix@pistache ~/project/BackEnd (*feature/cerberus-upgrade) $ python testcerberus.py 
Traceback (most recent call last):
  File "testcerberus.py", line 36, in <module>
    cerberus.Validator(schema)
  File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/validator.py", line 181, in __init__
    self.schema = kwargs.get('schema', None)
  File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/validator.py", line 562, in schema
    self._schema = DefinitionSchema(self, schema)
  File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/schema.py", line 76, in __init__
    self.validate(schema)
  File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/schema.py", line 247, in validate
    self._validate(schema)
  File "/home/moutix/.virtualenvs/BackEnd/lib/python3.6/site-packages/cerberus/schema.py", line 263, in _validate
    raise SchemaError(self.schema_validator.errors)
cerberus.schema.SchemaError: {'a': [{'valuesrules': [{'keyschema': ['unknown rule'], 'valueschema': ['unknown rule']}]}]}

When setting with valuesrule, it will properly work:

import cerberus

schema = {
    "a": {
        'type': 'dict',
        'valuesrules': {
            'type': 'dict',
            'keysrules': {
                'type': 'string',
            },
            'valuesrules': {
                'type': 'string'
            },
        }
    }
}

@ningirsu ningirsu changed the title Depreciation of keyschela and valueschema does not work when in subschema Depreciation of keyschema and valueschema does not work when in subschema Apr 30, 2019

@nicolaiarocci nicolaiarocci changed the title Depreciation of keyschema and valueschema does not work when in subschema Deprecation of keyschema and valueschema does not work when in subschema Apr 30, 2019

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 30, 2019

Fixes the renaming of deprecated rule names …
… where the rules also contain such.

Closes pyeve#482
@funkyfuture

This comment has been minimized.

Copy link
Member

commented Apr 30, 2019

thanks for reporting.

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 30, 2019

Fixes the renaming of deprecated rule names …
… where the rules also contain such.

Closes pyeve#482

@nicolaiarocci nicolaiarocci added this to the 1.3.1 milestone May 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.