npm i schema-utils
validateOptionsschema.jsonjs { "type": "object", "properties": { // Options... }, "additionalProperties": false } 
schema.jsonjs { "type": "object", "properties": { "option": { "type": [ "boolean" ] } }, // Overrides the default err.message for option "errorMessage": { "option": "should be {Boolean} (https:/github.com/org/repo#anchor)" } "additionalProperties": false } 
import schema from 'path/to/schema.json'
import validateOptions from 'schema-utils'
validateOptions(schema, options, 'Loader/Plugin Name')
schema.jsonjson { "type": "object", "properties": { "name": { "type": "string" }, "test": { "anyOf": [ { "type": "array" }, { "type": "string" }, { "instanceof": "RegExp" } ] }, "transform": { "instanceof": "Function" }, "sourceMap": { "type": "boolean" } }, "additionalProperties": false } 
Loaderimport { getOptions } from 'loader-utils'
import validateOptions from 'schema-utils'
import schema from 'path/to/schema.json'
function loader (src, map) {
  const options = getOptions(this) || {}
  validateOptions(schema, options, 'Loader Name')
  // Code...
}
Pluginimport validateOptions from 'schema-utils'
import schema from 'path/to/schema.json'
class Plugin {
  constructor (options) {
    validateOptions(schema, options, 'Plugin Name')
    this.options = options
  }
  apply (compiler) {
    // Code...
  }
}