Validators to be used as mixins in models
Project description
Validators to be used as mixins in models
Free software: MIT license
Usage
Install from pypi:
pip install styler-validation
Set validation rules for a class
from styler_validation import ValidatorMixin
from styler_validation import validators as va
class User(ValidatorMixin):
validates = [
('name', va.is_required()),
('age', va.is_required(), va.is_integer())
]
my_user = User()
result, errors = my_user.is_valid()
print(result) # False
print(errors) # {'user.name': 'Required field', 'user.age': 'Required field'}
my_user.name = 'John Doe'
my_user.age = 'nine'
result, errors = my_user.is_valid()
print(result) # False
print(errors) # {'user.age': 'Invalid value'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file styler_validation-0.1.0.tar.gz
.
File metadata
- Download URL: styler_validation-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f773399bfd0d4fcf1e67435292f4138549de3a3df6e717a639b18de075dcbb7 |
|
MD5 | 3d881107f5f15e70c002ea4a7d31f40d |
|
BLAKE2b-256 | 7e997be911793ecd4c336933515408f30ac36a3c9eab9f16fd02894926856e2b |
File details
Details for the file styler_validation-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: styler_validation-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb20016eb0a3708c2c091f0a490a2651d56fa418b34a029f4bf575a745858d4a |
|
MD5 | a312624bb36eefc707b12d1483d29db4 |
|
BLAKE2b-256 | ef798b628f1922807fd11d800b49c26e1eb2006196d109329b4d9bd93b50252c |