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