Skip to main content

Validate like maat

Project description

Maat

Build Status

Maat is a easy extensible transformation and validation library for Python. Build for corner cases.

The project is named after the ancient egyption god Maat. Her scale was used to weight the heart described in the book of the dead.

Since the scale is magical besides validating values it can transform them too.

Maat does dictionary to dictionary validation and transformation. from those two dictionary an new dictionary is created. Each value of dictionary to be validated is passed through their validator and transfomation functions

Examples

Validate that input name is of type str and is either 'John Doe' or 'Jane Doe'. Throws Invalid exception when validation fails, Maat has a fail fast policy.

    >>> import maat
    >>> user = {'name': 'John Doe'}
    >>> user_validation = {'name': {'validator': 'str', 'choices': ['John Doe', 'Jane Doe']}}
    >>> maat.scale(user, user_validation)
    {'name': 'John Doe'}
    
    >>> maat.scale({'name': 'peter pan'}, user_validation)
    Traceback (most recent call last):
    maat.validation.Invalid: key: "name" contains invalid item "peter pan": not in valid choices ['John Doe', 'Jane Doe']
    
    >>> maat.scale({'name': 42}, user_validation)
    Traceback (most recent call last)
    maat.validation.Invalid: key: "name" contains invalid item "42" with type "int": not of type string
    
    >>>  maat.scale({'user': 'John Doe'}, user_validation)
    Traceback (most recent call last)
    maat.validation.Invalid: invalid keys: user :expected keys: name
    
    >>> maat.scale({'name': 'Jane Doe'}, user_validation)
    {'name': 'Jane Doe'}

Authors

  • Melvin Bijman

License

This project is licensed under the MIT License - see the LICENSE file for details

Note

This project is being used in production by multiple companies.

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

Maat-0.8.6.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

Maat-0.8.6-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file Maat-0.8.6.tar.gz.

File metadata

  • Download URL: Maat-0.8.6.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for Maat-0.8.6.tar.gz
Algorithm Hash digest
SHA256 e573eb8312d38fa6ecf1536c4208418df215edc0db7d645bfc936a85c23057c6
MD5 83a59b0311e5d9ce77b842071a48416f
BLAKE2b-256 0b207439591c200d8737ff67fdcc48013d04127351c6e698aa1b1066018ea8f9

See more details on using hashes here.

File details

Details for the file Maat-0.8.6-py3-none-any.whl.

File metadata

  • Download URL: Maat-0.8.6-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for Maat-0.8.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f26b7d58e48d8a05b26c9967320814a9599dc47a7b53c55e337082b27fcdafae
MD5 abfdfdc4cc9ba60dd87026e71cb52319
BLAKE2b-256 5e14978920bb6d2427d91c8b865adb3b199489c64df309972aa908c6f2d9ab53

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