Registry / web-framework / definition-generator-framework

definition-generator-framework

JSON →
library2.1.2jsnpmunverified

A framework for generating definitions with custom validators, version 2.1.2. It integrates with Joi to provide custom validation decorators for file system operations. The framework is part of a monorepo and depends on helpers-lib, script-engine-lib, and Joi. Release cadence is not specified. Key differentiators include built-in custom validators and seamless integration with the definition generation ecosystem.

npm install definition-generator-framework
INSTALL
IMPORT
SIG · DEFINITION-GENERAT
D
definition-generator-framework
web-frameworkjavascriptv2.1.2
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.

JoiCustomValidators
import { JoiCustomValidators } from 'definition-generator-framework'
const JoiCustomValidators = require('definition-generator-framework').JoiCustomValidators
ESM recommended; CommonJS require works but destructure.
default
import definitionGeneratorFramework from 'definition-generator-framework'
const definitionGeneratorFramework = require('definition-generator-framework')
Default export available since v2.0.0.
SchemaGenerator
import { SchemaGenerator } from 'definition-generator-framework'
import SchemaGenerator from 'definition-generator-framework'
Named export, not default.

This example shows how to import and use JoiCustomValidators to decorate Joi with file system validators.

import * as fs from 'fs'; import { JoiCustomValidators } from 'definition-generator-framework'; // Decorate Joi with custom validators JoiCustomValidators.decorate(fs); // Now use Joi with custom validators, e.g., Joi.string().custom(fs.existsSync) const Joi = require('joi'); const schema = Joi.string().custom((value, helpers) => { if (!fs.existsSync(value)) { return helpers.error('any.invalid'); } return value; }); await schema.validateAsync('/path/to/file.txt'); console.log('Validation passed');
Debug
Known issues
breakingVersion 2.0.0 changed the default export from object to class. Use named imports for specific modules.
fix
Use named imports like { JoiCustomValidators } instead of default import.
affects: >=2.0.0 <2.1.0
deprecatedThe 'validateConfig' method is deprecated since v2.1.0. Use 'setupValidators' instead.
fix
Replace validateConfig() calls with setupValidators().
affects: >=2.1.0
gotchaJoiCustomValidators.decorate() must be called before any Joi validation that uses the custom validators.
fix
Ensure decorate() is called at application startup, before Joi schemas are compiled.
affects: >=1.0.0
gotchaIn Node.js, passing 'fs' directly to decorate works, but in browser environments you must provide a compatible mock.
fix
Provide a 'fs' mock object with required methods (existsSync, readFileSync, etc.).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot read properties of undefined (reading 'decorate')
JoiCustomValidators is undefined because import failed or wrong import syntax.
fix
Use correct import: import { JoiCustomValidators } from 'definition-generator-framework';
JoiCustomValidators.decorate is not a function
The decorator method was removed in v2.0.0, but the API changed.
fix
Upgrade to v2.1.0+ and use setupValidators instead, or downgrade to v1.x.
TypeError: Cannot read property 'existsSync' of undefined
The 'fs' object passed to decorate does not have existsSync.
fix
Ensure you import 'fs' correctly: import * as fs from 'fs'; then pass fs object.
Upgrade
Version history
2.1.2latest on npm
Audit
Dependencies
joirequiredRequired for schema validation
helpers-librequiredUtility functions used by the framework
script-engine-librequiredScript execution engine dependency
Agent activity
6 hits · last 30 days
node
6
Resources
definition-generator-framework — npm install definition-generator-framework · libregistry