{"id":25758,"library":"indicative-compiler","title":"Indicative Compiler","description":"Indicative Compiler is a low-level module used by Indicative, a validation library for Node.js, that compiles parsed schema into highly optimized executable functions. Current stable version is 7.2.4. It is part of the AdonisJS ecosystem and focuses on performance by generating optimized JavaScript functions from validation schemas during compilation. It uses a custom compiler pattern (ValidatorCompiler/ValidatorExecutor) and supports custom formatters and error collectors. Distinct from other validators like Joi or Yup by emphasizing ahead-of-time compilation for repeated validation runs. Typically paired with 'indicative-rules' and 'indicative-formatters'. Release cadence is irregular with major version bumps.","status":"active","version":"7.2.4","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/poppinss/indicative-compiler","tags":["javascript","indicative","compiler","ast"],"install":[{"cmd":"npm install indicative-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add indicative-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add indicative-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Validation rules used by the compiled functions","package":"indicative-rules","optional":false},{"reason":"Error formatting (VanillaFormatter etc.)","package":"indicative-formatters","optional":false}],"imports":[{"note":"Package is ESM-only? Since v7, possibly requires ESM import. Check Node.js version support.","wrong":"const { ValidatorCompiler } = require('indicative-compiler')","symbol":"ValidatorCompiler","correct":"import { ValidatorCompiler } from 'indicative-compiler'"},{"note":"Use named import.","wrong":"const ValidatorExecutor = require('indicative-compiler').ValidatorExecutor","symbol":"ValidatorExecutor","correct":"import { ValidatorExecutor } from 'indicative-compiler'"},{"note":"Exported since v7.2.1 for type usage. Previously misspelled as 'ValidationDefination'.","wrong":"","symbol":"ValidationDefinition","correct":"import { ValidationDefinition } from 'indicative-compiler'"}],"quickstart":{"code":"import { ValidatorCompiler, ValidatorExecutor } from 'indicative-compiler'\nimport { VanillaFormatter } from 'indicative-formatters'\nimport * as validations from 'indicative-rules'\n\nconst schema = {\n  username: 'required',\n  email: 'required|email'\n}\nconst messages = {}\n\n// Compile once\nconst compiledFunctions = new ValidatorCompiler(schema, messages).compile()\n\n// Execute with data\nconst data = { username: 'john', email: 'john@example.com' }\nconst result = await new ValidatorExecutor(compiledFunctions).exec(data, VanillaFormatter, {}, false, false)\nconsole.log(result)\n","lang":"typescript","description":"Shows typical usage: compile a validation schema and execute it against data with a formatter."},"warnings":[{"fix":"Update code to use ValidatorExecutor with compiled functions array.","message":"v7.0.0 introduced breaking changes: the compiler output structure changed, and the 'compile' method now returns an array instead of a single function.","severity":"breaking","affected_versions":">=7.0.0 <8.0.0"},{"fix":"Use 'ValidationDefinition' instead.","message":"The 'ValidationDefination' type (with typo) is deprecated in favor of 'ValidationDefinition' since v7.2.1.","severity":"deprecated","affected_versions":">=7.2.1"},{"fix":"Use 'indicative' as the main validation entry point.","message":"The package is low-level; you should typically use the 'indicative' package directly, not this one.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass the class reference (e.g., VanillaFormatter), not new VanillaFormatter().","message":"Formatters must be constructors, not instances. Passing an instance will cause runtime errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import { ValidatorCompiler } from 'indicative-compiler'","cause":"Using wrong import style (CommonJS default import instead of named import)","error":"TypeError: ValidatorCompiler is not a constructor"},{"fix":"Run npm install indicative-compiler","cause":"Package not installed or wrong path","error":"Cannot find module 'indicative-compiler'"},{"fix":"Replace 'ValidationDefination' with 'ValidationDefinition'","cause":"Typo in type name; the correct export is 'ValidationDefinition'","error":"ValidationDefination is not exported from indicative-compiler"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}