A TypeScript-first schema rule compiler and validation library that compiles declarative rule objects into efficient validation functions. Current stable version is 1.4.0 (released 2023). It has zero dependencies, supports both Node.js (>=16) and browsers, and is very small (minified+gzipped). Unlike runtime validation libraries like zod or yup, check-compiler provides a compiled check function for each schema, making repeated validation fast. It uses a type-driven rule definition with custom messages and supports nested objects, nullable values, and pattern validation. Ships TypeScript types.
npm install check-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a string rule with min, max, and pattern, compiles it, and validates two inputs, showing violation details.
Set nullable: true on the rule object when null is allowed.
Use the exact reason string as the key in the messages object (e.g., 'string pattern' for pattern violations).
Store compiled check functions and reuse them.
Use only supported types: 'string', 'number', 'object'. For others, consider custom validation.
Define a rule object: e.g., { type: 'number', min: 0 } instead of just 0.Use `import { Check } from 'check-compiler'` directly.Ensure the input argument matches the generic type used in compile<T>().
Switch to a supported type ('string', 'number', 'object') or implement custom validation.No dependency data recorded yet.