{"id":40709,"library":"check-compiler","title":"check-compiler","description":"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.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/akornatskyy/check-compiler-js","tags":["javascript","check","compiler","rules","schema","validation","typescript"],"install":[{"cmd":"npm install check-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add check-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add check-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Main function to compile a rule object into a check function. ESM only; CommonJS not supported.","symbol":"compile","correct":"import { compile } from 'check-compiler'"},{"note":"Type for defining a validation rule. Must be used with generic parameter, e.g., Rule<string>.","symbol":"Rule","correct":"import { Rule } from 'check-compiler'"},{"note":"Type for the compiled check function signature: (input: T, violations: Violation[]) => void.","symbol":"Check","correct":"import { Check } from 'check-compiler'"},{"note":"Interface describing a validation violation: location, message, reason, args.","symbol":"Violation","correct":"import { Violation } from 'check-compiler'"}],"quickstart":{"code":"import { compile, Rule, Violation } from 'check-compiler';\n\nconst nameRule: Rule<string> = {\n  type: 'string',\n  min: 2,\n  max: 50,\n  pattern: /^[a-zA-Z ]+$/,\n  messages: {\n    'string pattern': 'Only letters and spaces allowed.',\n  },\n};\n\nconst checkName = compile(nameRule);\n\nconst violations: Violation[] = [];\ncheckName('John Doe', violations);\nconsole.log(violations); // []\n\ncheckName('J', violations); // violates min\nconsole.log(violations[0].message); // The value must be at least 2 characters.","lang":"typescript","description":"Creates a string rule with min, max, and pattern, compiles it, and validates two inputs, showing violation details."},"warnings":[{"fix":"Set nullable: true on the rule object when null is allowed.","message":"Nullable fields require explicit nullable: true in the rule; otherwise null values cause violations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the exact reason string as the key in the messages object (e.g., 'string pattern' for pattern violations).","message":"Custom messages must use the same key as the built-in reason (e.g., 'string pattern', 'number range'). Incorrect keys are ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Store compiled check functions and reuse them.","message":"Calling compile() multiple times for the same rule is discouraged; compile once and reuse the check function.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use only supported types: 'string', 'number', 'object'. For others, consider custom validation.","message":"Unknown rule types (e.g., 'boolean', 'date') are not supported and will cause compilation errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.4.0':27 '16':37 '2023':29 'browser':39 'check':2,55,60,93 'check-compil':1,54 'compil':3,10,15,56,59,94 'current':23 'custom':78 'declar':16 'definit':76 'depend':33 'driven':74 'effici':20 'fast':68 'first':7 'function':22,61 'gzip':45 'javascript':92 'librari':13,49 'like':50 'make':65 'messag':79 'minifi':44 'nest':82 'node.js':36 'nullabl':84 'object':18,83 'pattern':87 'provid':57 'releas':28 'repeat':66 'rule':9,17,75,95 'runtim':47 'schema':8,64,96 'ship':89 'small':43 'stabl':24 'support':34,81 'type':73,91 'type-driven':72 'typescript':6,90,98 'typescript-first':5 'unlik':46 'use':70 'valid':12,21,48,67,88,97 'valu':85 'version':25 'yup':53 'zero':32 'zod':51","created_at":"2026-06-04T18:48:53.418082+00:00","updated_at":"2026-06-04T18:48:53.418082+00:00","problems":[{"fix":"Define a rule object: e.g., { type: 'number', min: 0 } instead of just 0.","cause":"Using a plain number/string where a Rule object is expected.","error":"Type 'number' has no properties in common with type 'Rule<unknown>'."},{"fix":"Use `import { Check } from 'check-compiler'` directly.","cause":"Importing Check incorrectly (e.g., `import { Check as CheckType }` instead of `import { Check }`).","error":"Cannot use namespace 'Check' as a type."},{"fix":"Ensure the input argument matches the generic type used in compile<T>().","cause":"Passing a value of mismatched type to a compiled check function.","error":"TS2345: Argument of type 'string' is not assignable to parameter of type 'never'."},{"fix":"Switch to a supported type ('string', 'number', 'object') or implement custom validation.","cause":"Attempting to use an unsupported rule type like 'boolean' or 'date'.","error":"Error: Unknown rule type: 'boolean'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/akornatskyy/check-compiler-js","github":"https://github.com/akornatskyy/check-compiler-js","docs":null,"changelog":null,"pypi":null,"npm":"check-compiler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}