Skip to main content

Validate library for python 3

Project description

travis-master coverall-master

dirty-validators

Agnostic validators for python 3

Freely based on [WTF-Forms](https://github.com/wtforms/wtforms) validators.

Features

  • Python 3 package.

  • Easy to create a validator.

  • Chained validations.

  • Conditional validations.

  • Specific error control messages.

  • Dirty model integration (https://github.com/alfred82santa/dirty-models)

  • No database dependent.

  • Asynchronous validators.

Changelog

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.

Installation

$ 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('abcdefg@test.com')

# 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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dirty_validators-0.5.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file dirty_validators-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: dirty_validators-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for dirty_validators-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3ad77e583d39c860d75fea2a040d819f79c20d23ebdd99531cd7f9c8cbb4f29
MD5 aed692ff1cda0ca4fcabb393f648b0f3
BLAKE2b-256 0dd5ce03bd76fbd10cd56a51058e63a03120704ff871f518f75a2e67453dedd2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page