{"_id":"@webpack-contrib/schema-utils","_rev":"144803","name":"@webpack-contrib/schema-utils","description":"Webpack Schema Validation Utilities","dist-tags":{"beta":"1.0.0-beta.0","latest":"1.0.0-beta.0"},"maintainers":[{"name":"d3viant0ne","email":"wiens.joshua@gmail.com"},{"name":"jhnns","email":"mail@johannesewald.de"}],"time":{"modified":"2021-06-03T11:29:01.000Z","created":"2018-04-02T04:23:10.386Z","1.0.0-beta.0":"2018-04-02T04:23:10.386Z"},"users":{},"author":{"name":"Webpack Contrib","url":"https://github.com/webpack-contrib"},"repository":{"type":"git","url":"git+https://github.com/webpack-contrib/schema-utils.git"},"versions":{"1.0.0-beta.0":{"name":"@webpack-contrib/schema-utils","version":"1.0.0-beta.0","description":"Webpack Schema Validation Utilities","license":"MIT","repository":{"type":"git","url":"git+https://github.com/webpack-contrib/schema-utils.git"},"author":{"name":"Webpack Contrib","url":"https://github.com/webpack-contrib"},"homepage":"https://github.com/webpack-contrib/schema-utils","bugs":{"url":"https://github.com/webpack-contrib/schema-utils/issues"},"main":"dist/cjs.js","engines":{"node":">= 6.9.0 || >= 8.9.0"},"scripts":{"start":"npm run build -- -w","build":"cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js' --copy-files","clean":"del-cli dist","commitlint":"commitlint","commitmsg":"commitlint -e $GIT_PARAMS","lint":"eslint --cache src test","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}","lint-staged":"lint-staged","prebuild":"npm run clean","prepublish":"npm run build","release":"standard-version","release:ci":"conventional-github-releaser -p angular","release:validate":"commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)","security":"nsp check","test":"jest","test:watch":"jest --watch","test:coverage":"jest --collectCoverageFrom='src/**/*.js' --coverage","ci:lint":"npm run lint && npm run security","ci:test":"npm run test -- --runInBand","ci:coverage":"npm run test:coverage -- --runInBand","defaults":"webpack-defaults"},"files":["dist/","schema/"],"keywords":["webpack"],"peerDependencies":{"webpack":"^3.0.0 || ^4.0.0"},"dependencies":{"ajv":"^6.1.0","ajv-keywords":"^3.1.0","chalk":"^2.3.2","strip-ansi":"^4.0.0","text-table":"^0.2.0","webpack-log":"^1.1.2"},"devDependencies":{"@commitlint/cli":"^5.2.8","@commitlint/config-angular":"^5.1.1","@webpack-contrib/eslint-config-webpack":"^2.0.2","babel-cli":"^6.26.0","babel-jest":"^22.4.3","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","conventional-github-releaser":"^2.0.0","cross-env":"^5.1.3","del":"^3.0.0","del-cli":"^1.1.0","eslint":"^4.17.0","eslint-plugin-import":"^2.8.0","eslint-plugin-prettier":"^2.6.0","husky":"^0.14.3","jest":"^22.4.3","lint-staged":"^6.1.0","memory-fs":"^0.4.1","nsp":"^3.1.0","pre-commit":"^1.2.2","prettier":"^1.10.2","standard-version":"^4.3.0","webpack":"^4.4.1","webpack-defaults":"^2.1.4"},"pre-commit":"lint-staged","lint-staged":{"*.js":["eslint --fix","git add"]},"gitHead":"a9a5a76fcee6acf763becd217e5f65e00bee8462","_id":"@webpack-contrib/schema-utils@1.0.0-beta.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"d3viant0ne","email":"wiens.joshua@gmail.com"},"dist":{"shasum":"bf9638c9464d177b48209e84209e23bee2eb4f65","size":7041,"noattachment":false,"key":"/@webpack-contrib/schema-utils/-/@webpack-contrib/schema-utils-1.0.0-beta.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@webpack-contrib/schema-utils/download/@webpack-contrib/schema-utils-1.0.0-beta.0.tgz"},"maintainers":[{"name":"d3viant0ne","email":"wiens.joshua@gmail.com"},{"name":"jhnns","email":"mail@johannesewald.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/schema-utils_1.0.0-beta.0_1522642990307_0.040111236727045974"},"_hasShrinkwrap":false,"publish_time":1522642990386,"_cnpm_publish_time":1522642990386}},"readme":"<div align=\"center\">\n  <a href=\"http://json-schema.org\">\n    <img width=\"200\"\n      src=\"https://cdn.rawgit.com/webpack-contrib/schema-utils/master/.github/json-schema-logo.svg\">\n  </a>\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![chat][chat]][chat-url]\n\n# schema-utils\n\nWebpack Schema Validation Utilities\n\nValidates `options` objects against a [JSON Schema](http://json-schema.org) and\ndisplays the output beautifully.\n\n<img width=\"645\"\n  src=\"https://cdn.rawgit.com/webpack-contrib/schema-utils/master/.github/pretty.png\">\n\n## Requirements\n\nThis module requires a minimum of Node v6.9.0 and Webpack v4.0.0.\n\n## Getting Started\n\nTo begin, you'll need to install `schema-utils`:\n\n```console\n$ npm install @webpack-contrib/schema-utils --save-dev\n```\n\n## API\n\nWhen using the API directly, the main entry point  is the `serve` function, which\nis the default export of the module.\n\n```js\nconst validate = require('@webpack-contrib/schema-utils');\nconst schema = require('path/to/schema.json');\nconst target = { ... }; // the options object to validate\nconst name = '...'; // the load or plugin name validate() is being used in\n\nvalidate({ name, schema, target });\n```\n\n### serve(options)\n\nReturns `true` if validation succeeded, `false` validation failed and options\nallow the function to return a value. (see options below).\n\n### options\n\nType: `Object`\n\nOptions for initializing and controlling the server provided. The option names\nlisted below belong to the `options` object.\n\n#### `exit`\n\nType: `Boolean`\nDefault: `false`\n\nIf `true`, will instruct the validator to end the process with an error code of\n`1`.\n\n#### `log`\n\nType: `Boolean`\nDefault: `false`\n\nIf `true`, will instruct the validator to log the results of the validation (in\nthe event of a failure) in a\n[webpack-style log output](https://github.com/webpack-contrib/webpack-log). This\nis typically used with `throw: false`.\n\n<img width=\"500\"\n  src=\"https://cdn.rawgit.com/webpack-contrib/schema-utils/master/.github/output-log-true.png\">\n\n#### `name`\n\nType: `String`\nDefault: `undefined`\n_**Required**_\n\nA `String` specifying the name of the loader or plugin utilizing the validator.\n\n#### `schema`\n\nType: `String|Object`\nDefault: `undefined`\n_**Required**_\n\nA `String` specifying the filesystem path to the schema used for validation.\nAlternatively, you may specify an `object` containing the JSON-parsed schema.\n\n#### `target`\n\nType: `Object`\nDefault: `undefined`\n_**Required**_\n\nAn `Object` containing the options to validate against the specified schema.\n\n#### `throw`\n\nType: `Boolean`\nDefault: `true`\n\nBy default the validator will throw an error and display validation results upon\nfailure. If this option is set to `false`, the validator will not throw an error.\nThis is typically used in situations where a return value of `false` for\n`validate()` is sufficient, a stack trace is uneeded, or when\n[webpack-style log output](https://github.com/webpack-contrib/webpack-log) is\npreferred.\n\n<img width=\"645\"\n  src=\"https://cdn.rawgit.com/webpack-contrib/schema-utils/master/.github/output-throws-true.png\">\n\n\n## Examples\n\nBelow is a basic example of how this validator might be used:\n\n```json\n# schema.json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"test\": {\n      \"anyOf\": [\n        { \"type\": \"array\" },\n        { \"type\": \"string\" },\n        { \"instanceof\": \"RegExp\" }\n      ]\n    },\n    \"transform\": {\n      \"instanceof\": \"Function\"\n    },\n    \"sourceMap\": {\n      \"type\": \"boolean\"\n    }\n  },\n  \"additionalProperties\": false\n}\n```\n\n### Use in a Loader\n\n```js\nconst { getOptions } = require('loader-utils');\nconst validate = require('@webpack-contrib/schema-utils');\n\nimport schema from 'path/to/schema.json'\n\nfunction loader (src, map) {\n  const options = getOptions(this) || {};\n\n  validate({ name: 'Loader Name', schema, target: options });\n\n  // Code...\n}\n```\n\n### Use in a Plugin\n\n```js\nconst validate = require('@webpack-contrib/schema-utils');\nconst schema = require('path/to/schema.json');\n\nclass Plugin {\n  constructor (options) {\n    validate({ name: 'Plugin Name', schema, target: options });\n\n    this.options = options;\n  }\n\n  apply (compiler) {\n    // Code...\n  }\n}\n```\n\n## License\n\n#### [MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/schema-utils.svg\n[npm-url]: https://npmjs.com/package/schema-utils\n\n[node]: https://img.shields.io/node/v/schema-utils.svg\n[node-url]: https://nodejs.org\n\n[deps]: https://david-dm.org/webpack-contrib/schema-utils.svg\n[deps-url]: https://david-dm.org/webpack-contrib/schema-utils\n\n[tests]: \thttps://img.shields.io/circleci/project/github/webpack-contrib/schema-utils.svg\n[tests-url]: https://circleci.com/gh/webpack-contrib/schema-utils\n\n[cover]: https://codecov.io/gh/webpack-contrib/schema-utils/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/schema-utils\n\n[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg\n[chat-url]: https://gitter.im/webpack/webpack","_attachments":{},"homepage":"https://github.com/webpack-contrib/schema-utils","bugs":{"url":"https://github.com/webpack-contrib/schema-utils/issues"},"license":"MIT"}