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:

  • integer(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.3.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

schematec-0.3.0-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file schematec-0.3.0.tar.gz.

File metadata

  • Download URL: schematec-0.3.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for schematec-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ebcc3366a6bffefcff56d7e240b4fa5b05e105dab182f10a1160a6fb2020dbfb
MD5 a1fadba1b40c30b1e3562162646fdf1f
BLAKE2b-256 c2a3a17414a6f1d2110f9359737137de7b287cff5a3135f9798fd928451e3243

See more details on using hashes here.

File details

Details for the file schematec-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for schematec-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8dd6d635cb77f1204a63521ad569fe72cb782fd19804936abe7d55358c0593c
MD5 02077c69da39b66e6bd5594e5ca6c6d7
BLAKE2b-256 83ab9122ed9a3db1f35c54d147ac24d010230da5727ff9ae7ea6319211fd53e0

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