Skip to main content

Data validation and transformation library for Python. Successor to CleanCat.

Project description

CleanChausie

CleanChausie is a data validation and transformation library for Python. It is a successor to CleanCat.

Check out the docs!

Interested in working on projects like this? Close is looking for great engineers to join our team.

Key features:

  • Operate on/with type-checked objects that have good IDE/autocomplete support
  • Annotation-based declarations for simple fields
  • Composable/reusable fields and field validation logic
  • Support (but not require) passing around a context (to avoid global state)
    • Context pattern is compatible with explicit sqlalchemy-based session management. i.e. pass in a session when validating
  • Cleanly support intra-schema field dependencies (i.e. one field can depend on the validated value of another)
  • Explicit nullability/omission parameters
  • Errors returned for multiple fields at a time, with field attribution

CleanChausie by example

This is a short example of how a schema might be used to support a flask endpoint. More detailed examples can be found in the docs.

from typing import List
from cleanchausie import (
  clean, ListField, URLField, EmailField, field, ValidationError, Schema
)
from flask import app, request, jsonify

class JobApplication(Schema):
  first_name: str
  last_name: str
  email: str = field(EmailField())
  urls: List[str] = field(ListField(URLField(default_scheme='http://')))

@app.route('/job_application', methods=['POST'])
def test_view():
  result = clean(JobApplication, request.json)
  if isinstance(result, ValidationError):
    return jsonify(result.serialize()), 400

  # Now "result" has the validated data, in the form of a `JobApplication` instance.
  assert isinstance(result, JobApplication)
  name = f'{result.first_name} {result.last_name}'

Release process

  • Make sure to thoroughly review and test the code changes.
  • Prepare for a new release
    • Update the package version within cleanchausie/__init__.py.
    • Add a changelog entry for the new version.
    • Merge to master
  • Dispatch a new "build and release" workflow action within the github actions tab.

The resulting workflow will build and publish the new version to PyPi.

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

cleanchausie-1.13.1.tar.gz (24.2 kB view details)

Uploaded Source

File details

Details for the file cleanchausie-1.13.1.tar.gz.

File metadata

  • Download URL: cleanchausie-1.13.1.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for cleanchausie-1.13.1.tar.gz
Algorithm Hash digest
SHA256 ef890c89139f9f56b40d3a59c4393ff6029499b9c19bce5d5ecd4e60e3b5d79f
MD5 af776edfbc4692918d14ff294e637896
BLAKE2b-256 3633039d8c3c9d2abf001ecc0de0b6ea8ad2b166eedad3a39255678582376535

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