Ez Validate
Simple package for data validation.
Examples:
Valid
var = 10.0
ValidateThat(var).is_float().less_than(12.4).greater_than(9.2)
Invalid
var = 5.0
ValidateThat(var).is_float().less_than(12.4).greater_than(9.2)
This example will raise ValidationError with the following message:
"Untitled var" must be greater than 9.2 but is 5.0
You can change the the name of variable by providing it in ValidateThat constractor:
ValidateThat(var, name='Your name').is_float().less_than(12.4).greater_than(9.2)
Your name must be greater than 9.2 but is 5.0
To handle the error use try except clause:
try:
...
except ValidationError as e:
...
Multiple conditions
And condition:
ValidateThat(var).firts_condition().second_condition().third_condition()
Or condition:
either(
lambda: ValidateThat(var).first_condition(),
lambda: ValidateThat(var).second_condition(),
lambda: ValidateThat(var).third_condition()
)
You can make combination of and and or conditions:
var = 1.5
either(
lambda: ValidateThat(var).is_float().less_than(3.0).greater_than(0.0),
lambda: ValidateThat(var).is_int().less_than(3).greater_than(0),
lambda: ValidateThat(var).is_none()
)
That would mean var must be:
- float and greater than 0 and less than 3.0
- or
- int and greater than 0 and less than 3
- or
- None
Release files for ez-validate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ez_validate-0.1.0.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ez_validate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:11.7 kB
Release files / ez_validate-0.1.0.tar.gz
| Download URL | ez_validate-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
583992ea95c6adda0ae671158d8522d5150d14f77ee2d27ca68dbeb6f0a89fe1
|
|
BLAKE2b-256 checksum How to use checksums |
e69ac76ffb513d369a05963ecb188b885d07ceae1ac8ec76c616a8d456eb5729
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ez_validate-0.1.0-py3-none-any.whl
| Download URL | ez_validate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
086d81a74eaf246abd298bf4f434b55a07f373d1c8337343080d0ab72bb343ab
|
|
BLAKE2b-256 checksum How to use checksums |
67afd57b5982cc32e68a8e0d5a6bb2ee0ddf6ed3cdb3dbeda0023eecddfb7b39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|