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

*of_check_with results in SchemaError due to unknown rule #484

Closed
3 tasks
jasongraham opened this issue Apr 30, 2019 · 1 comment
Closed
3 tasks

*of_check_with results in SchemaError due to unknown rule #484

jasongraham opened this issue Apr 30, 2019 · 1 comment
Assignees
Milestone

Comments

@jasongraham
Copy link

jasongraham commented Apr 30, 2019

Used Cerberus version / latest commit: 1.3

  • I have the capacity to improve the docs when my problem is solved.

  • I have the capacity to submit a patch when a bug is identified.

  • My question does not concern a practical use-case that I can't figure out
    to solve.


Use-case abstract

I'm attempting to replace the usage of validators within my schemas with check_with.

I've run into a problem trying to use *of_check_with.

My previous usage of *of_validator did indeed work just fine, and I would like to continue using this pattern.


Bug report / Feature request

Attempting to use check-with in place of validator within an *of typesaver structure results in a SchemaError being raised.

Example contents of test.py

import cerberus

# Arbitrary dummy validators
def foo(field, value, error):
    ...

def bar(field, value, error):
    ...

schema = {
    "a": {
        # Also fails with oneof, allof, noneof
        # replacing with *of_validator works
        "anyof_check_with": [foo, bar]
    }
}

cerberus.Validator(schema)

Result: of running python test.py

Traceback (most recent call last):
  File "test.py", line 20, in <module>
    cerberus.Validator(schema)
  File .../python3.7/site-packages/cerberus/validator.py", line 181, in __init__
    self.schema = kwargs.get('schema', None)
  File ".../python3.7/site-packages/cerberus/validator.py", line 562, in schema
    self._schema = DefinitionSchema(self, schema)
  File ".../python3.7/site-packages/cerberus/schema.py", line 76, in __init__
    self.validate(schema)
  File ".../python3.7/site-packages/cerberus/schema.py", line 247, in validate
    self._validate(schema)
  File ".../python3.7/site-packages/cerberus/schema.py", line 263, in _validate
    raise SchemaError(self.schema_validator.errors)
cerberus.schema.SchemaError: {'a': [{'anyof_check_with': ['unknown rule']}]}
@funkyfuture funkyfuture self-assigned this Apr 30, 2019
@funkyfuture funkyfuture added this to the 1.3.1 milestone Apr 30, 2019
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 30, 2019
@funkyfuture
Copy link
Member

thanks for reporting!

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