Skip to main content

No project description provided

Project description

JSON Schema Application Environment Configuration and Validation

This package allows you to validate application environment variables that are used for configuration with JSON schemas.

It is extremely useful to use with Docker/kubernetes where you might have quite a bit of configuration originating from environment variables; however, it also provides a nice generic way to define and validate any application configuration with JSON Schema.

Usage

First, define a JSON Schema file(env-schema.json):

{
    "$schema": "http://json-schema.org/draft-07/schema#", 
    "type": "object",
  
    "properties": {
        "db_uri": {
            "type": "string",
            "title": "AMQP host"
        }
    },
    "required": ["db_uri"]
}

Then, validate your environment config(export DB_URI=postgresql://localhost:5432):

import enviral
settings = enviral.validate_env('env-schema.json')
settings['db_uri']

Validate with multiple files:

import enviral
settings = enviral.validate_env('env-schema.json', 'package:validation-file.json')

You can also validate existing objects against JSON schema files:

import enviral
enviral.validate_object({"db_uri": "postgresql://localhost:5432"}, 'env-schema.json')

Or command line validate:

json-schema-env-validator env-schema.json package:validation-file.json

Development

pip install -r requirements.txt
pip install -e .
./bin/pre-commit install

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

json-schema-env-validator-1.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file json-schema-env-validator-1.0.2.tar.gz.

File metadata

  • Download URL: json-schema-env-validator-1.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for json-schema-env-validator-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3f97b0c122e568e6400c63b8c4ce1be627a4f3c0eb93df354c7cffcf4a1adca9
MD5 bc997dcdd83d81423c5b20a0f81db0b1
BLAKE2b-256 07896616ed8c913dc6b12110c0e1436393e235d5ac215254a4c487ec8f0f96ec

See more details on using hashes here.

File details

Details for the file json_schema_env_validator-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: json_schema_env_validator-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for json_schema_env_validator-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f819c10222e23218c2de55db518c4b7404d960f0873c7d702845e5e239f89c54
MD5 2b925aadb79c24752e51f1c74691fb50
BLAKE2b-256 986f252fdaa56ebe91ca5ed06ba8ec548498aa98ae87e0a615a2035aca34a50f

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page