Type Validation Made Simple with Tyck

Define validation schemas with clean, chainable syntax. Full Pydantic compatibility. Zero learning curve.

Read the Docs

Code Comparison

See the difference in syntax and discover how Tyck works seamlessly with Pydantic.

Pydantic

Verbose class-based definitions with Field descriptors

pydantic_example.py
from pydantic import BaseModel, Field
from typing import Optional, List
from email_validator import EmailStr

class User(BaseModel):
    id: int = Field(gt=0, description="User ID")
    name: str = Field(min_length=1, max_length=100)
    email: EmailStr = Field(description="User email")
    age: Optional[int] = Field(None, gt=0, lt=150)
    tags: List[str] = Field(default_factory=list, max_length=10)

# Create instance
user = User(id=1, name="John", email="john@example.com")
print(user.model_dump())

Tyck

Concise functional syntax with chainable validators

tyck_example.py
from Tyck import interface, String, Integer, Array, Optional

User = interface({
    'id': Integer.positive(),
    'name': String.min(1).max(100),
    'email': String.email(),
    'age': Optional(Integer.range(0, 150)),
    'tags': Array(String).max(10)
})

# Create instance
user = User(id=1, name="John", email="john@example.com")
print(user.model_dump())

Two Ways to Validate

Choose the style that fits your project. Both approaches offer the same powerful validation features.

Functional Approach

Best for quick schemas

Quick and concise schema definitions using the interface() function. Perfect for simple data validation, API responses, and configuration objects.

  • Minimal syntax
  • Dict-like definition
  • Inline configuration
functional.py
from Tyck import interface, String, Number, Integer, Array, Optional, config

# Quick functional schema definition
User = interface({
    'id': Integer.positive(),
    'name': String.min(1).max(100),
    'email': String.email(),
    'age': Optional(Number.gt(0).lt(150)),
    'tags': Array(String).max(10),
})

# With configuration
StrictUser = interface({
    'name': String,
    'email': String.email(),
}, config=config(
    strict=True,
    frozen=True,
    extra='forbid',
))

# Create instance
user = User(id=1, name="John", email="john@example.com")
print(user.model_dump())

Class-based Approach

Best for complex models

Full-featured classes with the @model() decorator. Add custom methods, inheritance, and more for complex domain models.

  • Custom methods
  • Inheritance support
  • Type annotations
class_based.py
from Tyck import model, String, Number, Integer, Array, Optional

@model()
class User:
    id: Integer.positive()
    name: String.min(1).max(100)
    email: String.email()
    age: Optional(Number.gt(0).lt(150))
    tags: Array(String).max(10)
    
    def greet(self) -> str:
        return f"Hello, {self.name}!"

# Create instance
user = User(id=1, name="John", email="john@example.com")
print(user.greet())  # "Hello, John!"

# Inheritance support
@model()
class Admin(User):
    role: String.default("admin")
    permissions: Array(String)

Why Tyck?

Built for Developer Productivity

Tyck enhances your Pydantic workflow with cleaner syntax and powerful utilities

60% Less Boilerplate

Clean, concise syntax without sacrificing power. Write less code while maintaining full type safety and validation.

Full Pydantic Compatibility

Built on Pydantic v2, works seamlessly with existing code. No migration headaches, just drop in and start using.

Flexible Approaches

Choose functional (interface) or class-based (@model) as needed. Use what fits your style and project requirements.

TypeScript-inspired Utilities

pick, omit, partial, extend, merge for schema composition. Transform and combine schemas with familiar patterns.

Zero Learning Curve

If you know Pydantic, you already know Tyck. Same concepts, same patterns, just simpler syntax.

Features

Why Choose Tyck

Everything you need for Python data validation

Lightning Fast

Minimal overhead over Pydantic v2. Define schemas in seconds with fluent method chaining.

Clean Syntax

No classes, no decorators for simple schemas. Define validation with readable dictionaries.

Type Safe

Full type inference and IDE autocomplete. Catch validation errors before runtime.

Pydantic Compatible

Built on Pydantic v2. Mix Tyck and Pydantic models seamlessly in the same project.

Utility Functions

TypeScript-inspired utilities: pick, omit, partial, extend, merge for schema transformations.

Easy Adoption

Start using Tyck today alongside existing Pydantic code. No migration required.

When to Use What

Choose the right approach based on your project requirements and complexity.

When to use Tyck

Best for lightweight, functional validation

  • Simple API input validation
  • Quick prototyping
  • Configuration schemas
  • Lightweight data parsing
  • Functional programming preference
  • Reducing boilerplate is priority

When to use Pydantic

Best for complex, customizable models

  • Complex business logic
  • Heavy customization needs
  • Custom validators required
  • Deep inheritance hierarchies
  • ORM integration
  • Maximum flexibility needed

When to use Hybrid

Best for flexible, mixed-complexity projects

  • Mix both in same project
  • Tyck for simple cases
  • Pydantic for complex cases
  • Seamless interoperability
  • Best of both worlds

FAQ

Frequently asked questions

Everything you need to know about Tyck.

Contact Us

Have questions or feedback? We'd love to hear from you.

Or reach us onTwitter