Registry / serialization / indicative-compiler

indicative-compiler

JSON →
library7.2.4jsnpmunverified

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.

npm install indicative-compiler
INSTALL
IMPORT
SIG · INDICATIVE-COMPILE
I
indicative-compiler
serializationjavascriptv7.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ValidatorCompiler
✓ import { ValidatorCompiler } from 'indicative-compiler'
✗ const { ValidatorCompiler } = require('indicative-compiler')
Package is ESM-only? Since v7, possibly requires ESM import. Check Node.js version support.
ValidatorExecutor
✓ import { ValidatorExecutor } from 'indicative-compiler'
✗ const ValidatorExecutor = require('indicative-compiler').ValidatorExecutor
Use named import.
ValidationDefinition
✓ import { ValidationDefinition } from 'indicative-compiler'
Exported since v7.2.1 for type usage. Previously misspelled as 'ValidationDefination'.

Shows typical usage: compile a validation schema and execute it against data with a formatter.

import { ValidatorCompiler, ValidatorExecutor } from 'indicative-compiler' import { VanillaFormatter } from 'indicative-formatters' import * as validations from 'indicative-rules' const schema = { username: 'required', email: 'required|email' } const messages = {} // Compile once const compiledFunctions = new ValidatorCompiler(schema, messages).compile() // Execute with data const data = { username: 'john', email: 'john@example.com' } const result = await new ValidatorExecutor(compiledFunctions).exec(data, VanillaFormatter, {}, false, false) console.log(result)
Debug
Known issues
breakingv7.0.0 introduced breaking changes: the compiler output structure changed, and the 'compile' method now returns an array instead of a single function.
fix
Update code to use ValidatorExecutor with compiled functions array.
affects: >=7.0.0 <8.0.0
deprecatedThe 'ValidationDefination' type (with typo) is deprecated in favor of 'ValidationDefinition' since v7.2.1.
fix
Use 'ValidationDefinition' instead.
affects: >=7.2.1
gotchaThe package is low-level; you should typically use the 'indicative' package directly, not this one.
fix
Use 'indicative' as the main validation entry point.
affects: all
gotchaFormatters must be constructors, not instances. Passing an instance will cause runtime errors.
fix
Pass the class reference (e.g., VanillaFormatter), not new VanillaFormatter().
affects: all
Errors
Common errors & fixes
TypeError: ValidatorCompiler is not a constructor
Using wrong import style (CommonJS default import instead of named import)
fix
Use import { ValidatorCompiler } from 'indicative-compiler'
Cannot find module 'indicative-compiler'
Package not installed or wrong path
fix
Run npm install indicative-compiler
ValidationDefination is not exported from indicative-compiler
Typo in type name; the correct export is 'ValidationDefinition'
fix
Replace 'ValidationDefination' with 'ValidationDefinition'
Upgrade
Version history
7.2.4latest on npm
Audit
Dependencies
indicative-rulesrequiredValidation rules used by the compiled functions
indicative-formattersrequiredError formatting (VanillaFormatter etc.)
Agent activity
10 hits · last 30 days
node
10
Resources
indicative-compiler — npm install indicative-compiler · libregistry