{"id":25161,"library":"definition-generator-framework","title":"Definition Generator Framework","description":"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.","status":"active","version":"2.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/sefabaser/definition-generator-framework","tags":["javascript"],"install":[{"cmd":"npm install definition-generator-framework","lang":"bash","label":"npm"},{"cmd":"yarn add definition-generator-framework","lang":"bash","label":"yarn"},{"cmd":"pnpm add definition-generator-framework","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for schema validation","package":"joi","optional":false},{"reason":"Utility functions used by the framework","package":"helpers-lib","optional":false},{"reason":"Script execution engine dependency","package":"script-engine-lib","optional":false}],"imports":[{"note":"ESM recommended; CommonJS require works but destructure.","wrong":"const JoiCustomValidators = require('definition-generator-framework').JoiCustomValidators","symbol":"JoiCustomValidators","correct":"import { JoiCustomValidators } from 'definition-generator-framework'"},{"note":"Default export available since v2.0.0.","wrong":"const definitionGeneratorFramework = require('definition-generator-framework')","symbol":"default","correct":"import definitionGeneratorFramework from 'definition-generator-framework'"},{"note":"Named export, not default.","wrong":"import SchemaGenerator from 'definition-generator-framework'","symbol":"SchemaGenerator","correct":"import { SchemaGenerator } from 'definition-generator-framework'"}],"quickstart":{"code":"import * as fs from 'fs';\nimport { JoiCustomValidators } from 'definition-generator-framework';\n\n// Decorate Joi with custom validators\nJoiCustomValidators.decorate(fs);\n\n// Now use Joi with custom validators, e.g., Joi.string().custom(fs.existsSync)\nconst Joi = require('joi');\nconst schema = Joi.string().custom((value, helpers) => {\n  if (!fs.existsSync(value)) {\n    return helpers.error('any.invalid');\n  }\n  return value;\n});\n\nawait schema.validateAsync('/path/to/file.txt');\nconsole.log('Validation passed');","lang":"typescript","description":"This example shows how to import and use JoiCustomValidators to decorate Joi with file system validators."},"warnings":[{"fix":"Use named imports like { JoiCustomValidators } instead of default import.","message":"Version 2.0.0 changed the default export from object to class. Use named imports for specific modules.","severity":"breaking","affected_versions":">=2.0.0 <2.1.0"},{"fix":"Replace validateConfig() calls with setupValidators().","message":"The 'validateConfig' method is deprecated since v2.1.0. Use 'setupValidators' instead.","severity":"deprecated","affected_versions":">=2.1.0"},{"fix":"Ensure decorate() is called at application startup, before Joi schemas are compiled.","message":"JoiCustomValidators.decorate() must be called before any Joi validation that uses the custom validators.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Provide a 'fs' mock object with required methods (existsSync, readFileSync, etc.).","message":"In Node.js, passing 'fs' directly to decorate works, but in browser environments you must provide a compatible mock.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use correct import: import { JoiCustomValidators } from 'definition-generator-framework';","cause":"JoiCustomValidators is undefined because import failed or wrong import syntax.","error":"Cannot read properties of undefined (reading 'decorate')"},{"fix":"Upgrade to v2.1.0+ and use setupValidators instead, or downgrade to v1.x.","cause":"The decorator method was removed in v2.0.0, but the API changed.","error":"JoiCustomValidators.decorate is not a function"},{"fix":"Ensure you import 'fs' correctly: import * as fs from 'fs'; then pass fs object.","cause":"The 'fs' object passed to decorate does not have existsSync.","error":"TypeError: Cannot read property 'existsSync' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}