Skip to content

API Reference

Complete API documentation for Flycatcher, organized by module.

📖 Overview

Flycatcher's API is organized into four main areas:

  • Schema - Core schema definition and validation
  • Fields - Field types and constraints
  • Validators - Custom field-level and cross-field validation DSL
  • Generators - Framework-specific output generators

🔍 Quick Navigation

Core Classes

  • Schema - Base class for defining schemas
  • Field - Base field class
  • FieldRef - Field reference for validator DSL

Field Types

  • Integer - Integer field with numeric constraints
  • Float - Float field with numeric constraints
  • String - String field with length and pattern constraints
  • Boolean - Boolean field
  • Datetime - Datetime field
  • Date - Date field

Validators

  • col() - Convenience alias for creating a field reference for validators
  • model_validator - Decorator for cross-field validation

Generators

📝 Usage Pattern

The typical workflow is:

  1. Define a schema using Schema, type hints, and Field()
  2. Add validators using @model_validator and the col() DSL
  3. Generate outputs using .to_pydantic(), .to_polars_validator(), or .to_sqlalchemy()
from flycatcher import Schema, Field, col, model_validator

class UserSchema(Schema):
    id: int = Field(primary_key=True)
    name: str = Field(min_length=1, max_length=100)
    age: int = Field(ge=0, le=120)

    @model_validator
    def check_age_name():
        return col('age') >= 18, "Must be 18 or older"

# Generate outputs
UserModel = UserSchema.to_pydantic()
UserValidator = UserSchema.to_polars_validator()
UserTable = UserSchema.to_sqlalchemy()