Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Value validation module

Project Description

This is a Python module that provides an easy way to validate values in other projects. The base class provides some generic comparisons and should be overridden in order to define comparisons for other classes.


Add the source as a submodule to your project.

$ git submodule add $ git submodule init


By overriding the functions class, validation functions can be added by data type or to the generic function list. Any function that is specified as generic may be used by any data of any type being validated.

class ValidatorFunctions(GenericValidatorFunctions):
def _add_typed_functions(self):
self._add_function(str, “contains”, contains) self._add_function(“generic”, “is_not_none”, is_not_none)
def contains(mine, yours):
return yours in mine
def is_not_none(mine, yours=None):
return mine is not None

Create a validator with an instance of the function class.

_validator_functions = ValidatorFunctions() validator = ValueValidator(_validator_functions)

Define a list of tuples that define the validation for the given value.

validations = [(‘contains’, ‘ell’), (‘is_not_none’, None)]

Run the validations against a value and keep an eye out for a ValidationError.

validator.validate(“hello, world!”, validations)
except ValidationError as validation_error:
print(“Value did not pass validation!”)
Release History

Release History

History Node


This version
History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting