{"action":"opened","issue":{"url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/265","repository_url":"https://api.github.com/repos/nicolaiarocci/cerberus","labels_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/265/labels{/name}","comments_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/265/comments","events_url":"https://api.github.com/repos/nicolaiarocci/cerberus/issues/265/events","html_url":"https://github.com/nicolaiarocci/cerberus/issues/265","id":176253535,"number":265,"title":"Creating custom Validator instance with `_validator_*` function raises Schema Error","user":{"login":"bryanwweber","id":4396228,"avatar_url":"https://avatars.githubusercontent.com/u/4396228?v=3","gravatar_id":"","url":"https://api.github.com/users/bryanwweber","html_url":"https://github.com/bryanwweber","followers_url":"https://api.github.com/users/bryanwweber/followers","following_url":"https://api.github.com/users/bryanwweber/following{/other_user}","gists_url":"https://api.github.com/users/bryanwweber/gists{/gist_id}","starred_url":"https://api.github.com/users/bryanwweber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryanwweber/subscriptions","organizations_url":"https://api.github.com/users/bryanwweber/orgs","repos_url":"https://api.github.com/users/bryanwweber/repos","events_url":"https://api.github.com/users/bryanwweber/events{/privacy}","received_events_url":"https://api.github.com/users/bryanwweber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-11T17:05:08Z","updated_at":"2016-09-11T17:05:08Z","closed_at":null,"body":"Used Cerberus version / latest commit: 1.0.1\r\n\r\n- I consulted these documentations:\r\n  - [x] http://docs.python-cerberus.org/en/stable/\r\n  - [x] http://docs.python-cerberus.org/en/latest/\r\n\r\n- I consulted these sections of the docs (add more lines as necessary):\r\n  - http://docs.python-cerberus.org/en/latest/customize.html#custom-validators\r\n\r\n- [ ] I found nothing relevant to my problem in the docs.\r\n- [x] I found the documentation not helpful to my problem.\r\n\r\n- [ ] I have the capacity to improve the docs when my problem is solved.\r\n- [x] I have the capacity to submit a patch when a bug is identified.\r\n\r\n----\r\n\r\n#### Use-case abstract\r\n\r\nI am trying to follow the example from the docs to create a custom validator. The example defining a function `oddity` works, but creating the custom subclass of `Validator` with the equivalent function raises a `SchemaError`.\r\n\r\n----\r\n```\r\nfrom cerberus import Validator\r\nclass AValidator(Validator):\r\n    def _validator_oddity(self, field, value):\r\n        if not value & 1:\r\n            self._error(field, \"Must be an odd number\")\r\n\r\nschema = {'amount': {'validator': 'oddity'}}\r\nv = AValidator(schema)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/Users/bryan/anaconda3/envs/pyteck/lib/python3.5/site-packages/cerberus/validator.py\", line 143, in __init__\r\n    self.schema = kwargs.get('schema', None)\r\n  File \"/Users/bryan/anaconda3/envs/pyteck/lib/python3.5/site-packages/cerberus/validator.py\", line 432, in schema\r\n    self._schema = DefinitionSchema(self, schema)\r\n  File \"/Users/bryan/anaconda3/envs/pyteck/lib/python3.5/site-packages/cerberus/schema.py\", line 67, in __init__\r\n    self.validate(schema)\r\n  File \"/Users/bryan/anaconda3/envs/pyteck/lib/python3.5/site-packages/cerberus/schema.py\", line 186, in validate\r\n    self._validate(schema)\r\n  File \"/Users/bryan/anaconda3/envs/pyteck/lib/python3.5/site-packages/cerberus/schema.py\", line 208, in _validate\r\n    raise SchemaError(self.schema_validator.errors)\r\ncerberus.schema.SchemaError: {'amount': [{'validator': [{'oneof': ['none or more than one rule validate', {'oneof definition 0': ['must be of callable type'], 'oneof definition 1': ['must be of list type'], 'oneof definition 2': ['unallowed value oddity']}]}]}]}\r\n```"}}
{"actor":{"display_login":"bryanwweber"}}