Skip to main content

Uniform - dress your form processing endpoints📋

Project description

uniform

Uniform

📋 Dress your form processing endpoints. 📋


Pipeline Status Coverage Report PyPI: uniform Code Style: Black


Introduction

Uniform is a form processing tool that can be easily plugged into your Starlette backend.

It gives you the following:

  • Extract and validate form data against typesystem.Schema
  • Return 400 Bad Request with validation problems explained
  • 100% test coverage.
  • 100% type annotated codebase.

Requirements

Python 3.6+

Installation

$ pip3 install uniform

Example

example.py:

import uvicorn

from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import PlainTextResponse
from typesystem import Schema, Boolean

from uniform import Uniform, validate

app = Starlette()


class TestSchema(Schema):
    test = Boolean()


@app.route("/")
@validate(Uniform(TestSchema))
async def home(request: Request) -> PlainTextResponse:
    return JSONResponse(
        content={"ok": True, "description": None, "result": dict(request.state.data)}
    )


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8080)

Then run the application...

$ python example.py

Send POST request to http://127.0.0.1:8080/ with application/json or application/x-www-form-urlencoded data and it will be validated.

Dependencies

Uniform work with starlette endpoints and validate forms using typesystem library.

If you want to parse application/x-www-form-urlencoded form data - you will also need a python-multipart.

— 📋 —

Uniform is Unlicensed code in Public Domain.

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

uniform-0.2.2.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

uniform-0.2.2-py3-none-any.whl (5.2 kB view hashes)

Uploaded 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