Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webpack-contrib/schema-utils

Package Overview
Dependencies
Maintainers
7
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webpack-contrib/schema-utils

Webpack Schema Validation Utilities

  • 1.0.0-beta.0
  • beta
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created

What is @webpack-contrib/schema-utils?

@webpack-contrib/schema-utils is a utility library for validating options against JSON schemas. It is commonly used in webpack plugins and loaders to ensure that user-provided options conform to expected formats.

What are @webpack-contrib/schema-utils's main functionalities?

Schema Validation

This feature allows you to validate an options object against a JSON schema. If the options do not match the schema, an error will be thrown.

const validate = require('@webpack-contrib/schema-utils');
const schema = {
  type: 'object',
  properties: {
    option: {
      type: 'string'
    }
  },
  additionalProperties: false
};
const options = { option: 'value' };
validate(schema, options, { name: 'MyPlugin' });

Custom Error Messages

You can catch validation errors and provide custom error messages to make debugging easier.

const validate = require('@webpack-contrib/schema-utils');
const schema = {
  type: 'object',
  properties: {
    option: {
      type: 'string'
    }
  },
  additionalProperties: false
};
const options = { option: 123 };
try {
  validate(schema, options, { name: 'MyPlugin' });
} catch (error) {
  console.error('Custom error message:', error.message);
}

Other packages similar to @webpack-contrib/schema-utils

Keywords

FAQs

Package last updated on 02 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc