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.
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dirty-validators-0.3.1.tar.gz.
File metadata
- Download URL: dirty-validators-0.3.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfb98d5656ac15b9138041765278016b468e15e5d9323eee60291f780c6abfd2
|
|
| MD5 |
a299560d1ed0e72146496e997b50431e
|
|
| BLAKE2b-256 |
2f0d967052012805cd76e9890536a256779cbc7bc0163bd67546dd9fe4915717
|