skillfed

trafaret

Validation and parsing library

trafaret v2.1.1 964.4K downloads/30d#4,625 on PyPI174
Permissive license BSD Abandoned released

What it is and what it does

Trafaret is a validation and data transformation library that lets you define schemas to check and convert incoming data—configs, JSON, form submissions, or any structured input. You write a schema once (using a shorthand syntax or composable validator objects), then call it to validate and transform data; if the data doesn't match, you get detailed error messages showing exactly what failed and where.

The library supports custom error messages, context passing during validation, and async checking via async_check. It has no runtime dependencies, making it lightweight to add to a project. However, the package has been abandoned since April 2022 with no recent commits, so it receives no maintenance or security updates.

Use it for:

  • Validate JSON payloads in web APIs before processing, catching malformed or missing fields early
  • Check and transform configuration files (YAML, JSON, TOML) at startup to ensure required keys and correct types
  • Validate and normalize form submissions in web applications, converting string inputs to the correct types
  • Build data pipelines that require strict schema enforcement, transforming data as it flows through stages
  • Parse and validate user input in CLI tools, ensuring arguments and options meet expected formats

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Trafaret validates and transforms foreign data (JSON, configs, user input) against schemas you define, with support for custom error messages and async checking.

Yes, if you need a lightweight, dependency-free validation library and can accept that the package is no longer maintained. The API is stable and works well for straightforward schema validation tasks. No, if you require active maintenance, security updates, or support for the latest Python versions—consider an actively maintained alternative like Pydantic or Marshmallow instead.

Install

trafaret on PyPI

pip

pip install trafaret

uv

uv add trafaret

poetry

poetry add trafaret

Installing trafaret

Before you install

Low install friction with no runtime dependencies. However, the package is abandoned—last release was 2022-04-01 and no commits since then. Use only if you accept the risk of no future maintenance or security updates.

License in practice

BSD license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install trafaret

import trafaret as t
validator = t.Dict(a=t.Int, b=t.List(t.String))
result = validator.check({'a': 5, 'b': ['lorem', 'ipsum']})

Verify before relying

  • Whether the package works reliably with modern Python versions (requires_python is unspecified in the fact sheet)
  • Whether async_check and aiohttp support mentioned in the description are fully functional in version 2.1.1

Package facts

License BSD (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,596 days since the last release
Last repo commit
First released
Downloads 964,396/month — #4,625 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: trafaret-2.1.1-py3-none-any.whl

Keywords: validation, form, forms, data, schema

Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3

Tags

data validation libraryschema validation pythonjson schema validatorconfig validationdata transformation validationform data validationstructured data checking
validationschema-checkingdata-transformation

More Software Development packages