Skip to main content

Builder-like data validation package

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ez_validate-0.0.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ez_validate-0.0.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file ez_validate-0.0.4.tar.gz.

File metadata

  • Download URL: ez_validate-0.0.4.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ez_validate-0.0.4.tar.gz
Algorithm Hash digest
SHA256 70323ae7f681a67a1e69d39a4572ef5e1357ad348f768d1289cd258a1834d1a5
MD5 94f9b500a7283e6418d1cce1e6da3256
BLAKE2b-256 eb8de968cac2cab6d9c78f1140947cf6124494619bd54700e4f5ef5bb2a3a128

See more details on using hashes here.

File details

Details for the file ez_validate-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ez_validate-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ez_validate-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 628a996f549c7f7133d2df9406f5768d65a16e278b801600105ffa1ae29080e0
MD5 88cfc784bbcb7670011e552cf0f03ad1
BLAKE2b-256 1bf8c2a2e37157c3b9962c3eefc9f81c88213bc5fce2573c7965b3fb9cc1d62b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page