Fortify Schema

Developer Documentation & API Reference

View on GitHub

TypeScript Schema Validation

A modern TypeScript validation library with interface-like syntax and powerful conditional validation

Quick Start

Installation

npm install fortify-schema
# or
bun add fortify-schema

Basic Usage

import { Interface } from "fortify-schema";

const UserSchema = Interface({
  id: "uuid",
  name: "string(2,50)",
  email: "email",
  age: "number(18,120)?",
  role: "admin|user|guest",
  tags: "string[]?",
  profile: {
    bio: "string?",
    avatar: "url?"
  }
});

// Validate data
const result = UserSchema.safeParse(userData);
if (result.success) {
  console.log("Valid:", result.data);
} else {
  console.log("Errors:", result.errors);
}

Key Features

๐ŸŽฏ

Type-Safe

Full TypeScript type inference with zero runtime overhead

โšก

High Performance

Optimized validation with precompilation and caching

๐Ÿ”ง

Powerful Utilities

Make and Mod utilities for schema transformation

๐ŸŽจ

Clean Syntax

Interface-like syntax that feels natural

๐Ÿ”€

Conditional Validation

Runtime conditional logic based on field values

๐Ÿ“ฆ

Array Support

Full support for arrays and nested objects

โœจ Recent Bug Fixes

We've fixed critical bugs in array-of-objects validation and type inference. Your schemas now work correctly with complex nested structures!

Learn more about the fixes

Explore Documentation