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_value',), 'user.age': ('required_value',)}
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-1.0.0.tar.gz
.
File metadata
- Download URL: styler_validation-1.0.0.tar.gz
- Upload date:
- Size: 7.1 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 | 4e605e86d6d1981175ba61ad2e2095c25f57a12cb64ae103692ac869a5eebcf7 |
|
MD5 | 06e3d25e60662692c875fceb1ee7e5fe |
|
BLAKE2b-256 | 8063ce1e916d19ad45aa9aea512e9f53d44e12504d6f9fc66fd89f2d835a565b |
File details
Details for the file styler_validation-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: styler_validation-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.3 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 | 614cf7e01ec91d267e7335530d05b1e5b3f8fc705ed769328c9579dcf334dee1 |
|
MD5 | f52e9c82efbad3f7bde9e2e10b5bb2c5 |
|
BLAKE2b-256 | 404d37347504142daa563b0d1f0b5a86010879aee7e4d045fea5091fd8e7e539 |