Skip to main content

Builder-like data validation package

Project description

Ez Validate

Simple package for data validation.

Examples:

Valid

var = 10.0
AssureThat(var).is_float().less_than(12.4).greater_than(9.2)

Invalid

var = 5.0
AssureThat(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 AssureThat constractor:

AssureThat(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:

AssureThat(var).firts_condition().second_condition().third_condition()

Or condition:

either(
	lambda: AssureThat(var).first_condition(),
	lambda: AssureThat(var).second_condition(),
	lambda: AssureThat(var).third_condition()
)

You can make combination of and and or conditions:

var = 1.5
either(
	lambda: AssureThat(var).is_float().less_than(3.0).greater_than(0.0),
	lambda: AssureThat(var).is_int().less_than(3).greater_than(0),
	lambda: AssureThat(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.2.tar.gz (4.3 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.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ez_validate-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 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.2.tar.gz
Algorithm Hash digest
SHA256 396e68bcd1f8c0de14a73635a31ed6ed41517b861d2301168458b14f5f91134a
MD5 bd24b831064a780be5ad6aa6aa2aea90
BLAKE2b-256 e1d75b5c56351f37f80c7434a4c1e532c5272cd652c0929f3204668c17f60a1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ez_validate-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 856bdc01853fa7dd992eeffbdd74c2ff9f013977dba09334782679921d23eb84
MD5 7f62359dba15c05ae37a3a1eacc17ec9
BLAKE2b-256 4c18055e772760857baf6f86e427e45ef9e5c42e4b0c1cbe6a5baf862a097329

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