Skip to main content

Set of tools that makes input data validation easier

Project description

Schematec

Schematec is a set of tools that brings some static typing into Python and makes input data validation easier. The purpose of this code is attempt to bring simplicity to applications logics using separation of data validation and actual data processing.

Concepts

Schematec separates concept of validation and concept of types casting.

Object deconstruction seems reasonable useful for input data filtering.

Workflow

Schematec determine validity of data using following criterias:

  1. Existence (schema validator)

  2. Type (converter)

  3. Suitability (validator)

Example:

a = string and email and required

### Cases

{'a': 'mylokin@me.com'}  # valid
{'a': 'mylokin'}  # invalid by suitability
{'a': ''}  # invalid by suitability
{'a': 1}  # invalid by suitability
{'a': None}  # invalid by type
{'a': []}  # invalid by type
{}  # invalid by existence

a = string and email

### Cases

{'a': 'mylokin@me.com'}  # valid
{'a': 'mylokin'}  # invalid by suitability
{'a': ''}  # invalid by suitability
{'a': 1}  # invalid by suitability
{'a': None}  # invalid by type
{'a': []}  # invalid by type
{}  # valid

a = string

### Cases

{'a': 'mylokin@me.com'}  # valid
{'a': 'mylokin'}  # valid
{'a': ''}  # valid
{'a': 1}  # valid
{'a': None}  # invalid by type
{'a': []}  # invalid by type
{}  # valid

Glossary

Validator

Configurable object that checks object for predefined conditions.

Converter

Converter casts input object to required type if possible.

Schema

Set of validators

Validation

Checking process where every value validated through set of validators.

Validators

Required – any

Required value, (everything is optional by default).

Regex (URL, Email, IPAddress) – string

String contains expected value.

Range – integer

Integer within range

Length – string, array, dictionary

Length of iteratable is appropriate.

Supported Data Types

Schematec supports subset of JSON data types:

Basic types:

  • numeric(int)

  • string(str)

  • boolean(bool)

Containers:

  • array(list)

  • dictionary(dict)

Extended Data Types

  • datetime - based on str

  • regexp str - based on str

Order of schema check

  1. Unbound Validators

  2. Converters

  3. Bound Validators

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

schematec-0.2.0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

schematec-0.2.0-py2.py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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