Skip to main content

FastAPI Assets

Python Versions FastAPI License Code Style

A powerful validation and assertion toolkit for FastAPI applications.

Documentation · Examples · Contributing


Overview

FastAPI Assets is a comprehensive validation toolkit designed specifically for FastAPI applications. It simplifies the process of validating file uploads, request metadata, and HTTP parameters, ensuring that your application handles user input securely and efficiently.

FastAPI Assets provides:

  • File Validators - Validate file uploads with size, MIME type, and filename checks
  • Image Validators - Specialized validation for image files (format, dimensions, aspect ratio)
  • CSV Validators - Validate CSV structure, encoding, columns, and row counts
  • Request Validators - Validate headers, query parameters, path parameters, and cookies
  • Custom Validators - Create custom validation logic with sync or async support
  • Granular Error Messages - Fine-grained error control for precise user feedback
  • Type-Safe - Full type hints and runtime type validation
  • Light Weight - Minimal dependencies; optional extras for specific features

Quick Start

Installation

# Basic installation
pip install fastapi-assets

# With image support (includes Pillow)
pip install fastapi-assets[image]

# With CSV support (includes pandas)
pip install fastapi-assets[pandas]

# With all optional features
pip install fastapi-assets[image,pandas]

Features

File Validators

  • FileValidator - General-purpose file validation

    • File size validation (min/max with human-readable formats)
    • MIME type validation with wildcard support
    • Filename pattern validation
    • Custom validator functions
  • ImageValidator - Specialized image validation

    • Image format validation (JPEG, PNG, WebP, GIF, BMP, TIFF)
    • Image dimension validation
    • Aspect ratio validation
    • Inherits all FileValidator features
  • CSVValidator - CSV file validation (requires pandas)

    • CSV encoding validation
    • Required/disallowed columns
    • Row count validation
    • Header-only validation option

Request Validators

  • HeaderValidator - HTTP header validation

    • Pattern matching with regex
    • Predefined formats (UUID4, email, Bearer token, etc.)
    • Allowed values restriction
    • Custom validators
  • QueryValidator - Query parameter validation

    • Type conversion and validation
    • Allowed values restriction
    • Numeric range validation
    • Pattern matching
  • PathValidator - Path parameter validation

    • Type conversion
    • Pattern matching
    • Range validation
  • CookieValidator - Cookie value validation

    • Pattern matching
    • Required value validation
    • Custom validators

Advanced Features

  • Granular Error Messages - Customize error messages for each validation type
  • Custom Validators - Add custom validation logic (sync or async)
  • HTTP Status Codes - Customize HTTP response codes per validator
  • Type Safety - Full type hints for IDE support and type checking

Documentation

Comprehensive documentation is available at https://openverge.github.io/fastapi-assets/

Project Structure

fastapi-assets/
├── fastapi_assets/
│   ├── core/                    # Core validation framework
│   │   ├── base_validator.py   # Abstract base validator
│   │   └── exceptions.py        # Custom exceptions
│   ├── validators/              # File validators
│   │   ├── file_validator.py
│   │   ├── image_validator.py
│   │   ├── csv_validator.py
│   │   └── utils.py
│   └── request_validators/      # HTTP request validators
│       ├── header_validator.py
│       ├── query_validator.py
│       ├── path_validator.py
│       └── cookie_validator.py
├── tests/                       # Comprehensive test suite
├── docs/                        # Documentation
└── pyproject.toml              # Project configuration

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Code of Conduct

Please read CODE_OF_CONDUCT.md before contributing.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.


FastAPI Assets - Making FastAPI validation simple, secure, and intuitive.

Version 0.1.0 | Last Updated: November 2025

Metadata

Release files for fastapi-assets 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-assets 0.1.0
File Size Uploaded Provenance Actions
fastapi_assets-0.1.0.tar.gz 77.0 kB Without provenance Details for fastapi_assets-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-assets 0.1.0
File Interpreter ABI Platform Actions
fastapi_assets-0.1.0-py3-none-any.whl Python 3 none any Details for fastapi_assets-0.1.0-py3-none-any.whl

Total release size: 109.6 kB

Release files / fastapi_assets-0.1.0.tar.gz

Download URL fastapi_assets-0.1.0.tar.gz
Size 77.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cc057f921b11d8a4f983ca8db6f3b166b5acbb9ce61e777d75d213b55d1273ef
BLAKE2b-256 checksum
How to use checksums
c5178dc6bd9df37d83b3dfeb1c0b05778529a81745bbb5f113426acfe7d9004f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / fastapi_assets-0.1.0-py3-none-any.whl

Download URL fastapi_assets-0.1.0-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fd0d426448d8227841f939506be64ceafb643193738c1ca08d8eaaf1a3af129
BLAKE2b-256 checksum
How to use checksums
66894d351352a7eee24e04d4fb48cf3cf4d56fdee5e0063edb5949c08bdba8ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for fastapi-assets 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page