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.3.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.3-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ez_validate-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 0a4bac7e6e376d6899efe54f987b6c4159d37dcbd3db1d509f950039ab56f26f
MD5 d366bc79bcce433d5eca456784a13b8e
BLAKE2b-256 a3f978c7bc3f46446469e63e00fb9d43863a635875f219ef0262a85ceb09e7c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ez_validate-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c1c51f1bd39e373ea3117ad989581abf355c34b2771b70d053ae6ccca43b4df
MD5 b8ee899eb6521f9008eb160028ae418e
BLAKE2b-256 20126718c38a6d79bf4e23b3e304dc363fd252bd4d02056d6a4065cb2f2795e3

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