The fortify-schema package is being deprecated and replaced by reliant-type.
While fortify-schema will continue to receive critical security patches, all new features, performance improvements, and ongoing development are now focused exclusively on reliant-type. We strongly recommend migrating to reliant-type for:
- Latest features and improvements - All new capabilities are built into
reliant-type - Active development - Ongoing enhancements and optimizations
- Long-term support - Full maintenance and community support
- Enhanced performance - Significant speed and efficiency gains
- Expanded ecosystem - Growing tooling and integration support
Migration is straightforward - reliant-type maintains API compatibility with fortify-schema core features while introducing powerful new capabilities. See our Migration Guide for step-by-step instructions.
// Before (fortify-schema)
import { Interface } from "fortify-schema";
// After (reliant-type)
import { Interface } from "reliant-type";
// Your existing schemas work without modification
const UserSchema = Interface({
id: "uuid",
email: "email!",
name: "string(2,50)",
});Fortify Schema is a TypeScript validation library featuring interface-like syntax and advanced conditional validation. Designed for TypeScript developers who value familiar patterns and powerful runtime validation capabilities.
- Interface-like Syntax - Define schemas using TypeScript-style interface definitions
- Advanced Conditionals - Implement complex business logic with
whenexpressions - Custom Error Messages - Provide context-specific validation feedback using the
-->operator - Complete Type Safety - Full TypeScript inference with zero runtime overhead
- High Performance - Automatic precompilation and optimization
- Professional Tooling - VS Code extension with IntelliSense and real-time validation
npm install fortify-schemaNote: For new projects, consider starting with reliant-type instead:
npm install reliant-typeimport { Interface } from "fortify-schema";
// Define schemas with familiar TypeScript-like syntax
const UserSchema = Interface({
id: "uuid",
email: "email! --> Please provide a valid email address",
name: "string(2,50) --> Name must be between 2 and 50 characters",
age: "number(18,120)? --> Age must be between 18 and 120",
role: "admin|user|guest --> Role must be admin, user, or guest",
tags: "string[]",
metadata: "record<string, any>",
// Advanced conditional validation
permissions: "when role=admin *? string[] : =[]",
});
// Validate with complete TypeScript inference
const result = UserSchema.safeParse(userData);
if (result.success) {
console.log("Valid user:", result.data); // Fully typed
} else {
console.log("Validation errors:", result.errors);
}Comprehensive support for primitive types, collections, and advanced formats:
- Primitives -
string,number,boolean,null,undefined - Specialized -
email,url,uuid,date,iso8601 - Collections - Arrays (
string[]), Records (record<string, any>) - Objects - Generic object validation with
objectandobject? - Unions - Enumerated values with
admin|user|guest
- Optional - Mark fields as optional with
?suffix (e.g.,"string?") - Required - Enforce non-empty values with
!suffix (e.g.,"email!") - Constraints - Apply ranges and limits with
(min,max)syntax - Custom Messages - Define user-friendly errors with
-->operator
Implement complex business rules based on runtime data:
const ProductSchema = Interface({
inStock: "boolean",
discount: "when inStock=true *? number(0,100)? : =0",
maxQuantity: "when inStock=true *? int(1,1000) : int(1,10)",
});const FormSchema = Interface({
email: "email! --> Please enter a valid email",
password: "string(8,)! --> Password must be at least 8 characters",
confirmPassword: "string --> Passwords must match",
terms: "boolean! --> You must accept the terms",
});const APIRequestSchema = Interface({
method: "GET|POST|PUT|DELETE",
endpoint: "url",
headers: "record<string, string>",
body: "object?",
});const ProductSchema = Interface({
id: "uuid",
name: "string(3,100)",
price: "number(0.01,) --> Price must be greater than 0",
category: "electronics|clothing|food",
inStock: "boolean",
discount: "when inStock=true *? number(0,100)? : =0",
});const UserSchema = Interface({
id: "uuid",
email: "email!",
role: "admin|user|guest",
permissions: "when role=admin *? string[] : =[]",
maxProjects: "when role=admin *? int(1,100) : int(1,3)",
});Enhance your development workflow with professional IDE integration:
- Syntax Highlighting - Comprehensive highlighting for schema types
- IntelliSense - Context-aware autocompletion
- Hover Documentation - Inline documentation and examples
- Error Detection - Real-time schema syntax validation
- Code Snippets - Pre-built templates for common patterns
Download Extension | Extension Documentation
Fortify Schema is optimized for production environments:
- Fast Validation - Optimized execution paths with schema precompilation
- Memory Efficient - Minimal overhead per schema instance
- Scalable - Predictable performance across data complexity levels
- Benchmarked - Continuous performance monitoring and optimization
Run benchmarks locally:
npm run benchmark
npm run benchmark:nestedObject| Feature | Fortify Schema | Reliant-Type | Zod | Yup | Joi |
|---|---|---|---|---|---|
| Interface-like syntax | Yes | Yes | No | No | No |
| Conditional validation | Yes | Enhanced | Limited | No | Limited |
| Custom error messages | Yes | Yes | Yes | Yes | Yes |
| TypeScript inference | Full | Full | Full | Limited | No |
| VS Code extension | Yes | Yes | No | No | No |
| Active development | Maintenance | Active | Active | Active | Active |
| Bundle size | Small | Small | Medium | Large | Large |
Note: reliant-type represents the evolution of fortify-schema with enhanced capabilities and ongoing development.
- GitHub Issues - Bug reports and feature requests
- Discord Community - Community discussions
- Documentation - Comprehensive guides and API reference
Contributions are welcome. Please review our Contributing Guide before submitting pull requests.
- Report bugs and request features
- Submit pull requests
- Improve documentation
- Share use cases and feedback
MIT © Nehonix Team
Developed by the Nehonix Team with contributions from the open-source community.
Special recognition to:
- The TypeScript team for language innovation
- The open-source community for feedback and contributions
- All contributors and users of Fortify Schema

