question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UserWarning while running sample code for class-based Validator

See original GitHub issue

I have copied an example code for class-based Validator from here : http://cerberus-sanhe.readthedocs.io/customize.html#class-validator

from cerberus import Validator

class MyValidator(Validator):
    def _validate_isodd(self, isodd, field, value):
        if isodd and not bool(value & 1):
            self._error(field, "Must be an odd number")

Unfortunately the code emits user warning: (python3.5, cerberus 1.1)

/usr/local/lib/python3.5/dist-packages/cerberus/validator.py:1338: UserWarning: No validation schema is defined for the arguments of rule 'isodd'
  "'%s'" % method_name.split('_', 2)[-1])

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
olegsvcommented, Mar 20, 2018

@funkyfuture turns out the docstring is important. The following code works:

class MyValidator(Validator):
    def _validate_isodd(self, isodd, field, value):
        """ Test the oddity of a value.
        The rule's arguments are validated against this schema:
        {'type': 'boolean'}
        """
        if isodd and not bool(value & 1):
            self._error(field, "Must be an odd number")

1reaction
D-stefaangcommented, Dec 11, 2019

Note that you need to include this text literally

        The rule's arguments are validated against this schema:
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 2.7 Openpyxl UserWarning - Stack Overflow
This error happens when openpyxl cannot understand/read an extension (source). Here is the list of built-in extensions openpyxl currently ...
Read more >
Trainer — PyTorch Lightning 1.8.5.post0 documentation
Automatically enabling/disabling grads. Running the training, validation and test dataloaders. Calling the Callbacks at the appropriate times. Putting batches ...
Read more >
How To Use Custom Form Validation in Angular - DigitalOcean
In this tutorial, you will construct a custom validator for a phone number input field in an Angular application.
Read more >
Model Explanation — AutoSklearn 0.15.0 documentation
Click here to download the full example code or to run this example in your browser ... /auto-sklearn/autosklearn/data/target_validator.py:187: UserWarning: ...
Read more >
Multi-Class Imbalanced Classification
In this tutorial, we will focus on the standard imbalanced multi-class ... Although there are minority classes, all classes are equally ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found