Skip to main content

Validate library for python 3

Project description

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.

  • Specific error control messages.

  • No database dependent.

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 Distribution

dirty-validators-0.1.5.tar.gz (8.0 kB view details)

Uploaded Source

File details

Details for the file dirty-validators-0.1.5.tar.gz.

File metadata

File hashes

Hashes for dirty-validators-0.1.5.tar.gz
Algorithm Hash digest
SHA256 38ee9b1a5bfebe1e3dc8d84c94b38b36bd60e1a9e4c1a0dd6e8013fba5dfb90f
MD5 86ffe0553a143ea7a10bd5aa92895a8d
BLAKE2b-256 1aa42bc48dd96f1f0e61a93aeb4278765dd4f4b86ea36f08c643533bfce0d841

See more details on using hashes here.

Supported by

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