Skip to main content

Validate library for python 3

Project description

travis-master coverall-master


Agnostic validators for python 3

Freely based on [WTF-Forms]( validators.


  • Python 3 package.
  • Easy to create a validator.
  • Chained validations.
  • Conditional validations.
  • Specific error control messages.
  • Dirty model integration (
  • No database dependent.
  • Asynchronous validators.


Version 0.5.4

  • Allow model validator inheritance.

Version 0.5.2

  • Remove hard dependency from Dirty Models.
  • Fix bug iterating ListModels.

Version 0.5.1

  • Added value validators for mappings.

Version 0.5.0

  • Added asynchronous validators.

Version 0.4.0

  • Added <root> keyword in order to look up a field from root model of context.
  • Added key_validator argument for spec validators in order to validate keys on hashmaps.


$ pip install dirty-validators

Basic usage

from dirty_validators.basic import EqualTo, Length, Regexp, Email
from dirty_validators.complex import Optional, ModelValidate

validator = Optional(validators=[EqualTo(comp_value="test")])

assert validator.is_valid("test") is True

# Chained validation
validator_chain = Chain(validators=[Length(min=14, max=16), Regexp(regex='^abc'), Email()])

assert validator_chain.is_valid('')

# Model validation

class MyModelValidator(ModelValidate):
    fieldName1 = Optional(validators=[Length(min=4, max=6)])
    fieldName2 = Optional(validators=[Length(min=1, max=2)])
    fieldName3 = Required(validators=[Length(min=7, max=8)])

validator_model = MyModelValidator()

data = {
    "fieldName1": "1234",
    "fieldName1": "12",
    "fieldName3": "123456qw"

assert validator_model.is_valid(FakeModel(data)) is True


Look at tests for more examples

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dirty-validators, version 0.5.4
Filename, size File type Python version Upload date Hashes
Filename, size dirty_validators-0.5.4-py3-none-any.whl (13.0 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page