Skip to main content

This is a Flask Plugin to be used for Validate JSON request data.

Project description

This is a Flask Plugin to be used for Validate JSON request data.

This package uses jsonschema to for validation: https://pypi.python.org/pypi/jsonschema

jsonschema documentation: https://json-schema.org/understanding-json-schema/index.html

Usage

This package provides a flask route decorator to validate json payload.

from flask import Flask,g
from flask_validate_json import validate_json


app = Flask(__name__)

schema = {
    'type': 'object',
    'properties': {
        'name': {'type': 'string'},
        'email': {'type': 'string'},
        'password': {'type': 'string'}
    },
    'required': ['email', 'password']
}


@app.route('/register', methods=['POST'])
@validate_json(schema)
def register():
    # if payload is invalid, request will be aborted with error code 400
    # if payload is valid it is stored in g.json_data

    # do something with your data
    # example: user = User().from_dict(g.json_data)

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

flask-validate-json-0.0.1.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file flask-validate-json-0.0.1.tar.gz.

File metadata

  • Download URL: flask-validate-json-0.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6

File hashes

Hashes for flask-validate-json-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1ad8a0d12c7472c1a8b6cbad0875cc32035533746873be973827b1e3d3a79084
MD5 c041ff85c5777f6a0f4e0e54ca940cad
BLAKE2b-256 8ce9aa8b4855636a389100f3da4dc8e5e55723c4d71497a4df193cffb3be3226

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