{"library":"schema-utils","title":"schema-utils","description":"Schema validation utility for webpack loaders, plugins, and other configuration objects. Version 4.3.3 is the latest stable release, actively maintained alongside webpack. It provides a validate() function that checks options against a JSON Schema, with clear error messages including the plugin/loader name and data path. Differentiates from generic validators like ajv by being tailored for webpack's configuration context, supporting post-formatting of errors and a configuration object for naming. Ships TypeScript types and has both ESM and CJS builds. Primarily used internally by webpack but also directly by custom loaders and plugins.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install schema-utils"],"cli":null},"imports":["import { validate } from 'schema-utils'","import { ValidationError } from 'schema-utils'","import type { Schema } from 'schema-utils'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { validate } from 'schema-utils';\nimport schema from './schema.json' with { type: 'json' };\n\nconst options = { mode: 'production', devtool: 'source-map' };\nconst configuration = { name: 'MyPlugin', baseDataPath: 'options' };\n\ntry {\n  validate(schema, options, configuration);\n  console.log('Options are valid');\n} catch (error) {\n  if (error instanceof TypeError && error.name === 'ValidationError') {\n    console.error('Validation failed:', error.message);\n  }\n}","lang":"typescript","description":"Demonstrates validating options against a JSON schema with error handling, using a custom name and base data path. The import uses JSON with assertion for ES modules.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}