{"name":"schema-utils","version":"2.5.0","description":"webpack Validation Utils","license":"MIT","repository":{"type":"git","url":"git+https://github.com/webpack/schema-utils.git"},"author":{"name":"webpack Contrib","url":"https://github.com/webpack-contrib"},"homepage":"https://github.com/webpack/schema-utils","bugs":{"url":"https://github.com/webpack/schema-utils/issues"},"main":"dist/index.js","types":"index.d.ts","engines":{"node":">= 8.9.0"},"scripts":{"start":"npm run build -- -w","prebuild":"npm run clean","build":"cross-env NODE_ENV=production babel src -d dist --ignore \"src/**/*.test.js\" --copy-files","clean":"del-cli dist","commitlint":"commitlint --from=master","lint:prettier":"prettier \"{**/*,*}.{js,json,md,yml,css}\" --list-different","lint:js":"eslint --cache src test","lint":"npm-run-all -l -p \"lint:**\"","prepare":"npm run build","release":"standard-version","security":"npm audit","test:only":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:coverage":"cross-env NODE_ENV=test jest --collectCoverageFrom=\"src/**/*.js\" --coverage","pretest":"npm run lint","test":"cross-env NODE_ENV=test npm run test:coverage","defaults":"webpack-defaults"},"dependencies":{"ajv":"^6.10.2","ajv-keywords":"^3.4.1"},"devDependencies":{"@babel/cli":"^7.6.2","@babel/core":"^7.6.2","@babel/preset-env":"^7.6.2","@commitlint/cli":"^8.2.0","@commitlint/config-conventional":"^8.2.0","@types/json-schema":"^7.0.3","@webpack-contrib/defaults":"^5.0.2","@webpack-contrib/eslint-config-webpack":"^3.0.0","babel-jest":"^24.9.0","commitlint-azure-pipelines-cli":"^1.0.2","cross-env":"^6.0.0","del":"^5.1.0","del-cli":"^3.0.0","eslint":"^6.4.0","eslint-config-prettier":"^6.3.0","eslint-plugin-import":"^2.18.2","husky":"^3.0.5","jest":"^24.9.0","jest-junit":"^8.0.0","lint-staged":"^9.4.0","npm-run-all":"^4.1.5","prettier":"^1.18.2","standard-version":"^7.0.0"},"keywords":["webpack"],"gitHead":"b98e06cda3cd207ba9f35ca972c601c017700d2d","_id":"schema-utils@2.5.0","_nodeVersion":"10.15.2","_npmVersion":"6.12.0","dist":{"integrity":"sha512-32ISrwW2scPXHUSusP8qMg5dLUawKkyV+/qIEV9JdXKx+rsM6mi8vZY8khg2M69Qom16rtroWXD3Ybtiws38gQ==","shasum":"8f254f618d402cc80257486213c8970edfd7c22f","tarball":"http://registry-npm.ywwl.com/schema-utils/download/schema-utils-2.5.0.tgz","fileCount":10,"unpackedSize":51438,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdpbZOCRA9TVsSAnZWagAAl1sP/A8SkPNkiuu/mfyoGUR/\nskJ5UdS7VHa3uVaMvkmOYx46bd9zRbC2Q+E0MbVLMXVtePecr6qykbQ31SHa\nCAMoa4OvllhCsCldfYdXH7vSO496CCMu3Km2joeph6q36IOxrjqXSeol9Sbs\nM8VYiMyNRQWUNQhd8IUK6Vk4UtOGcOurzVMghCJBCNK4/KzUSnhhMmHwv1oq\ndrWcvPx5nNN9d2hJxB2jN0kUIM2oVbPKVo4VtJaQzQcxBQkeGmKVRlUIXP5+\n2M1GE717nJF2vicCzphncX7R9p5Dv0NUzjykN+hKtyhXZop0wYkXjFwv2GLj\n+3Qk2VRj3NRwVQZsMoBFZfahsT2xfLQa5k8EO4lKgD5o6UQql7i6L+HIMLzx\n2T0SQPy+QCW9zEHt5SScNtJ27TysvASj/cTjrXYcIQMBji0TW01eJrzf4mBC\nJVdCppp2SG7K53UZGw/eGisEX+e7PvLNHGSQPHsOwy3421dn8rXwHx98aelE\nJpNA4VYJMQRnCFRBAhp87YVvlwEPfGPt4DxsKNIYgR3DydXlFYURAoUOQ18n\nowJjQYfc99ME/TgF43l2tuFz1m2zTOVg5zg07NWhlLY7ZRiRRQwXebRoUS9R\n6XGpzFK07uo8GBqicym+Zd1EyB3hdcBuYM+z/kui4boGq665k4OiDy8LUiqh\n9h4z\r\n=eC5B\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDKX99UhNT94GNWQArgi/xfDVOEAmzMMSyZP5ACAXYy4QIhAKln68qLwYuNm6zShE9id63mm24jZAWmEEiC/Pplhow7"}],"size":12360,"noattachment":false,"key":"/schema-utils/-/schema-utils-2.5.0.tgz"},"maintainers":[{"email":"bebraw@gmail.com","name":"bebraw"},{"email":"wiens.joshua@gmail.com","name":"d3viant0ne"},{"email":"sheo13666q@gmail.com","name":"evilebottnawi"},{"email":"michael.ciniawsky@gmail.com","name":"michael-ciniawsky"},{"email":"tobias.koppers@googlemail.com","name":"sokra"}],"_npmUser":{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/schema-utils_2.5.0_1571141197865_0.07724758074500793"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <a href=\"http://json-schema.org\">\n    <img width=\"160\" height=\"160\"\n      src=\"https://raw.githubusercontent.com/webpack-contrib/schema-utils/master/.github/assets/logo.png\">\n  </a>\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\"\n      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[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![GitHub Discussions][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# schema-utils\n\nPackage for validate options in loaders and plugins.\n\n## Getting Started\n\nTo begin, you'll need to install `schema-utils`:\n\n```console\nnpm install schema-utils\n```\n\n## API\n\n**schema.json**\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"option\": {\n      \"type\": \"boolean\"\n    }\n  },\n  \"additionalProperties\": false\n}\n```\n\n```js\nimport schema from \"./path/to/schema.json\";\nimport { validate } from \"schema-utils\";\n\nconst options = { option: true };\nconst configuration = { name: \"Loader Name/Plugin Name/Name\" };\n\nvalidate(schema, options, configuration);\n```\n\n### `schema`\n\nType: `String`\n\nJSON schema.\n\nSimple example of schema:\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"description\": \"This is description of option.\",\n      \"type\": \"string\"\n    }\n  },\n  \"additionalProperties\": false\n}\n```\n\n### `options`\n\nType: `Object`\n\nObject with options.\n\n```js\nimport schema from \"./path/to/schema.json\";\nimport { validate } from \"schema-utils\";\n\nconst options = { foo: \"bar\" };\n\nvalidate(schema, { name: 123 }, { name: \"MyPlugin\" });\n```\n\n### `configuration`\n\nAllow to configure validator.\n\nThere is an alternative method to configure the `name` and`baseDataPath` options via the `title` property in the schema.\nFor example:\n\n```json\n{\n  \"title\": \"My Loader options\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"description\": \"This is description of option.\",\n      \"type\": \"string\"\n    }\n  },\n  \"additionalProperties\": false\n}\n```\n\nThe last word used for the `baseDataPath` option, other words used for the `name` option.\nBased on the example above the `name` option equals `My Loader`, the `baseDataPath` option equals `options`.\n\n#### `name`\n\nType: `Object`\nDefault: `\"Object\"`\n\nAllow to setup name in validation errors.\n\n```js\nimport schema from \"./path/to/schema.json\";\nimport { validate } from \"schema-utils\";\n\nconst options = { foo: \"bar\" };\n\nvalidate(schema, options, { name: \"MyPlugin\" });\n```\n\n```shell\nInvalid configuration object. MyPlugin has been initialised using a configuration object that does not match the API schema.\n - configuration.optionName should be a integer.\n```\n\n#### `baseDataPath`\n\nType: `String`\nDefault: `\"configuration\"`\n\nAllow to setup base data path in validation errors.\n\n```js\nimport schema from \"./path/to/schema.json\";\nimport { validate } from \"schema-utils\";\n\nconst options = { foo: \"bar\" };\n\nvalidate(schema, options, { name: \"MyPlugin\", baseDataPath: \"options\" });\n```\n\n```shell\nInvalid options object. MyPlugin has been initialised using an options object that does not match the API schema.\n - options.optionName should be a integer.\n```\n\n#### `postFormatter`\n\nType: `Function`\nDefault: `undefined`\n\nAllow to reformat errors.\n\n```js\nimport schema from \"./path/to/schema.json\";\nimport { validate } from \"schema-utils\";\n\nconst options = { foo: \"bar\" };\n\nvalidate(schema, options, {\n  name: \"MyPlugin\",\n  postFormatter: (formattedError, error) => {\n    if (error.keyword === \"type\") {\n      return `${formattedError}\\nAdditional Information.`;\n    }\n\n    return formattedError;\n  },\n});\n```\n\n```shell\nInvalid options object. MyPlugin has been initialized using an options object that does not match the API schema.\n - options.optionName should be a integer.\n   Additional Information.\n```\n\n## Examples\n\n**schema.json**\n\n```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### `Loader`\n\n```js\nimport { getOptions } from \"loader-utils\";\nimport { validate } from \"schema-utils\";\n\nimport schema from \"path/to/schema.json\";\n\nfunction loader(src, map) {\n  const options = getOptions(this);\n\n  validate(schema, options, {\n    name: \"Loader Name\",\n    baseDataPath: \"options\",\n  });\n\n  // Code...\n}\n\nexport default loader;\n```\n\n### `Plugin`\n\n```js\nimport { validate } from \"schema-utils\";\n\nimport schema from \"path/to/schema.json\";\n\nclass Plugin {\n  constructor(options) {\n    validate(schema, options, {\n      name: \"Plugin Name\",\n      baseDataPath: \"options\",\n    });\n\n    this.options = options;\n  }\n\n  apply(compiler) {\n    // Code...\n  }\n}\n\nexport default Plugin;\n```\n\n### Allow to disable and enable validation (the `validate` function do nothing)\n\nThis can be useful when you don't want to do validation for `production` builds.\n\n```js\nimport { disableValidation, enableValidation, validate } from \"schema-utils\";\n\n// Disable validation\ndisableValidation();\n// Do nothing\nvalidate(schema, options);\n\n// Enable validation\nenableValidation();\n// Will throw an error if schema is not valid\nvalidate(schema, options);\n\n// Allow to undestand do you need validation or not\nconst need = needValidate();\n\nconsole.log(need);\n```\n\nAlso you can enable/disable validation using the `process.env.SKIP_VALIDATION` env variable.\n\nSupported values (case insensitive):\n\n- `yes`/`y`/`true`/`1`/`on`\n- `no`/`n`/`false`/`0`/`off`\n\n## Contributing\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\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[node]: https://img.shields.io/node/v/schema-utils.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/schema-utils/workflows/schema-utils/badge.svg\n[tests-url]: https://github.com/webpack/schema-utils/actions\n[cover]: https://codecov.io/gh/webpack/schema-utils/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/schema-utils\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.com/badge?p=schema-utils\n[size-url]: https://packagephobia.com/result?p=schema-utils\n","publish_time":1571141197995,"_cnpm_publish_time":1571141197995,"dist-tags":{"latest":"4.8.5","version-3":"3.3.0"}}