fortify-schema
| Install | |
|---|---|
npm install fortify-schema |
|
| Latest Version: | 2.2.1 |
| License: | MIT License |
| Last Updated: | Dec 24, 2025 |
| Links: | GitHub · npm |
Fortify Schema
Important: Migration to Reliant-Type
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.
Quick Migration Example
// 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)",
});
Overview
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.
Key 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
Installation
npm install fortify-schema
Note: For new projects, consider starting with reliant-type instead:
npm install reliant-type
Quick Start
import { 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);
}
Core Features
Type System
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
Validation Modifiers
- 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
Conditional Validation
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)",
});
Documentation
Getting Started
Core Concepts
Advanced Features
Reference
Common Use Cases
Form Validation
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",
});
API Request Validation
const APIRequestSchema = Interface({
method: "GET|POST|PUT|DELETE",
endpoint: "url",
headers: "record<string, string>",
body: "object?",
});
E-Commerce Products
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",
});
User Management
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)",
});
VS Code Extension
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
Performance
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
Comparison
| 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.
Community & Support
Get Help
- GitHub Issues - Bug reports and feature requests
- Discord Community - Community discussions
- Documentation - Comprehensive guides and API reference
Contributing
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
Stay Updated
License
MIT © Nehonix Team
Acknowledgments
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
Related Packages
A modern TypeScript validation library designed around familiar interface syntax...
Fast, zero-config SAST CLI for JavaScript & TypeScript — Node.js backends and fr...
Type-safe Fetch HTTP client with retries, interceptors, validation, and multi-ho...
Version History
| Version | Released | License |
|---|---|---|
| 2.2.1 | MIT License | |
| 2.2.0 | MIT License | |
| 2.1.3 | MIT License | |
| 2.1.2 | MIT License | |
| 2.1.1 | MIT License | |
| 2.1.0 | MIT License | |
| 2.0.21 | MIT License | |
| 2.0.20 | MIT License | |
| 2.0.19 | MIT License | |
| 2.0.18 | MIT License | |
| 2.0.17 | MIT License | |
| 2.0.16 | MIT License | |
| 2.0.15 | MIT License | |
| 2.0.14 | MIT License | |
| 2.0.13 | MIT License | |
| 2.0.12 | MIT License | |
| 2.0.11 | MIT License | |
| 2.0.10 | MIT License | |
| 2.0.9 | MIT License | |
| 2.0.8 | MIT License | |
| 2.0.7 | MIT License | |
| 2.0.6 | MIT License | |
| 2.0.5 | MIT License | |
| 2.0.4 | MIT License | |
| 2.0.3 | MIT License | |
| 2.0.1 | GNU Affero General Public License v3 | |
| 2.0.0 | GNU Affero General Public License v3 | |
| 1.1.5 | GNU Affero General Public License v3 | |
| 1.1.4 | GNU Affero General Public License v3 | |
| 1.1.3 | GNU Affero General Public License v3 |
Showing the latest 30 of 47. See every release on npm