Skip to main content

Damn Simple Validation Kit.

Project description

About

Validate dict-like object against schema, using just callables.

Features

  • Allows validating and sanitizing dicts using any callables

  • Provides several useful helpers

  • Easy to use – no class-based boilerplate!

API

validate function takes any mapping as data and another mapping as scheme and check data against scheme. It returns list of errors.

sanitize function takes any mapping as data and another mapping as scheme and converts data according to schema definition.

For more info – see tests.

Examples

Several schemes:

schema = {
    'key1': str,
    'key2': int,
    'key3': int,
}

schema1 = {
    'key1': kuvalda.list_of(int),
    'key2': kuvalda.list_of(kuvalda.list_of(int))
}

schema2 = {
   'section1': {
       'key1': str,
       'key2': int
    },
    'section2': kuvalda.mapping(str, int),
    'key1': kuvalda.kind_of(bool)
}

schema3 = {
    'key1': int,
    'key2': kuvalda.default('oh, my'),
    'key3': kuvalda.optional(int),
    'key4': kuvalda.optional(kuvalda.list_of(int)),
    'key5': kuvalda.compose(kuvalda.default(42), int)
}

Install

~/yourvirtualenv/python setup.py install

pip install kuvalda

License

The MIT License, in LICENSE file.

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

kuvalda-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

kuvalda-0.1.0.macosx-10.12-x86_64.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file kuvalda-0.1.0.tar.gz.

File metadata

  • Download URL: kuvalda-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for kuvalda-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a88eb3bfd9ac07754556dca795631220affa1d8f4058fe9f36f39a517bf4b5b
MD5 050185a608b1a7dd4203ed12ade96d89
BLAKE2b-256 7dbdcda7d86b4cc4ad7d9fc6b235eaa25a948cb325b04f913413457ba80a470b

See more details on using hashes here.

File details

Details for the file kuvalda-0.1.0.macosx-10.12-x86_64.tar.gz.

File metadata

File hashes

Hashes for kuvalda-0.1.0.macosx-10.12-x86_64.tar.gz
Algorithm Hash digest
SHA256 fa6510f0da6c5b7c1853ea685a9117db78de221b6865cf45ebee09ce9a464166
MD5 6a5a0da8871801919068e9fc2f9fc70f
BLAKE2b-256 02274562b150d3b085b75b920e8491ad3cf24cd241cbdb3acfd549901cd35c8b

See more details on using hashes here.

Supported by

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