Skip to main content

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)

Source distribution for ez-validate 0.1.0
File Size Uploaded
ez_validate-0.1.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ez-validate 0.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page