pax_global_header00006660000000000000000000000064133323444500014513gustar00rootroot0000000000000052 comment=6ca2322d4c8c5818c4a8f71328ac88e3507ec4e8 schema-utils-1.0.0/000077500000000000000000000000001333234445000141075ustar00rootroot00000000000000schema-utils-1.0.0/.editorconfig000066400000000000000000000002231333234445000165610ustar00rootroot00000000000000root = true [*] charset = utf-8 indent_size = 2 end_of_line = lf indent_style = space insert_final_newline = true trim_trailing_whitespace = true schema-utils-1.0.0/.eslintignore000066400000000000000000000000161333234445000166070ustar00rootroot00000000000000/node_modules schema-utils-1.0.0/.eslintrc.js000066400000000000000000000004001333234445000163400ustar00rootroot00000000000000module.exports = { root: true, plugins: [ 'prettier' ], extends: [ '@webpack-contrib/eslint-config-webpack' ], rules: { 'prettier/prettier': [ 'error', { singleQuote: true, trailingComma: 'es5', arrowParens: 'always' } ] } }; schema-utils-1.0.0/.gitattributes000066400000000000000000000001011333234445000167720ustar00rootroot00000000000000yarn.lock -diff * text=auto bin/* eol=lf package-lock.json -diffschema-utils-1.0.0/.github/000077500000000000000000000000001333234445000154475ustar00rootroot00000000000000schema-utils-1.0.0/.github/CODEOWNERS000066400000000000000000000003111333234445000170350ustar00rootroot00000000000000# These are the default owners for everything in # webpack-contrib @webpack-contrib/org-maintainers # Add repository specific users / groups # below here for libs that are not maintained by the org. schema-utils-1.0.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001333234445000176325ustar00rootroot00000000000000schema-utils-1.0.0/.github/ISSUE_TEMPLATE/BUG.md000066400000000000000000000023301333234445000205670ustar00rootroot00000000000000--- name: 🐛 Bug about: Report a Bug --- ### Details ### Error (Logs|Stacks) ### Reproduction (Code) ```bash $ git clone https://github.com// ``` ### Environment |OS|node|npm/yarn|package| |:-:|:--:|:-:|:------:| |[name][version]|[version]|[version]|[version]| schema-utils-1.0.0/.github/ISSUE_TEMPLATE/DOCS.md000066400000000000000000000012241333234445000207030ustar00rootroot00000000000000--- name: 📖 Docs about: Report documentation related issues --- ### Type - [ ] Other - [ ] Wrong - [ ] Unclear - [ ] Missing ### Details ### Location - [ ] README - [ ] LICENSE - [ ] CHANGELOG - [ ] ISSUE_TEMPLATE - [ ] BUG - [ ] DOCS - [ ] FEATURE - [ ] PULL_REQUEST_TEMPLATE schema-utils-1.0.0/.github/ISSUE_TEMPLATE/FEATURE.md000066400000000000000000000007141333234445000212510ustar00rootroot00000000000000--- name: 🌟 Feature about: Request a feature --- ### Proposal ### Use Case ### Implementation - [ ] I'm open to work on this - [ ] I need help/mentorship - [ ] I'm unable to work on this schema-utils-1.0.0/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000042461333234445000212560ustar00rootroot00000000000000### Notable Changes #### `Commit Message Summary (CHANGELOG)` ```bash # Commit Message Body # # Example BREAKING CHANGE: requires `node >= v8.0.0` BREAKING CHANGE: `options.x` requires to be a `{Function}` now ``` ### Type > ℹ️ What type of changes does your code introduce? - [ ] CI - [ ] Fix - [ ] Perf - [ ] Docs - [ ] Test - [ ] Style - [ ] Build - [ ] Chore - [ ] Feature - [ ] Refactor ### Issues > ℹ️ What issue(s) (if any) are closed by your PR? - Fixes `#1` ### SemVer > ℹ️ What changes to the current `semver` range does your PR introduce? - [ ] Fix (:label: Patch) - [ ] Feature (:label: Minor) - [ ] Breaking Change (:label: Major) ### Checklist > ℹ️ You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. This is a reminder of what we are going to look for before merging your code. - [ ] I have signed the CLA - [ ] Lint and unit tests pass with my changes - [ ] I have added tests that prove my fix is effective/works (if needed) - [ ] I have added necessary documentation (if appropriate) - [ ] Any dependent changes are merged and published in downstream modules schema-utils-1.0.0/.gitignore000066400000000000000000000003331333234445000160760ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* # Build .eslintcache /dist /local /reports /coverage /node_modules # Editor & OS .idea .vscode *.sublime-project *.sublime-workspace DS_Store .DS_Store Thumbs.db schema-utils-1.0.0/.npmrc000066400000000000000000000000231333234445000152220ustar00rootroot00000000000000package-lock=false schema-utils-1.0.0/.prettierrc000066400000000000000000000001171333234445000162720ustar00rootroot00000000000000{ "singleQuote": true, "trailingComma": "es5", "arrowParens": "always" } schema-utils-1.0.0/.travis.yml000066400000000000000000000006471333234445000162270ustar00rootroot00000000000000language: node_js jobs: fast_finish: true include: - stage: Lint env: SCRIPT=lint node_js: 'stable' - &test stage: 'Test' env: SCRIPT=test node_js: 'stable' - <<: *test node_js: 'lts/*' - <<: *test node_js: 6 - <<: *test node_js: 4 script: npm run $SCRIPT after_success: - 'bash <(curl -s https://codecov.io/bash)' notifications: email: false schema-utils-1.0.0/CHANGELOG.md000066400000000000000000000112301333234445000157150ustar00rootroot00000000000000# Change Log All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. # [1.0.0](https://github.com/webpack-contrib/schema-utils/compare/v0.4.7...v1.0.0) (2018-08-07) ### Features * **src:** add support for custom error messages ([#33](https://github.com/webpack-contrib/schema-utils/issues/33)) ([1cbe4ef](https://github.com/webpack-contrib/schema-utils/commit/1cbe4ef)) ## [0.4.7](https://github.com/webpack-contrib/schema-utils/compare/v0.4.6...v0.4.7) (2018-08-07) ### Bug Fixes * **src:** `node >= v4.0.0` support ([#32](https://github.com/webpack-contrib/schema-utils/issues/32)) ([cb13dd4](https://github.com/webpack-contrib/schema-utils/commit/cb13dd4)) ## [0.4.6](https://github.com/webpack-contrib/schema-utils/compare/v0.4.5...v0.4.6) (2018-08-06) ### Bug Fixes * **package:** remove lockfile ([#28](https://github.com/webpack-contrib/schema-utils/issues/28)) ([69f1a81](https://github.com/webpack-contrib/schema-utils/commit/69f1a81)) * **package:** remove unnecessary `webpack` dependency ([#26](https://github.com/webpack-contrib/schema-utils/issues/26)) ([532eaa5](https://github.com/webpack-contrib/schema-utils/commit/532eaa5)) ## [0.4.5](https://github.com/webpack-contrib/schema-utils/compare/v0.4.4...v0.4.5) (2018-02-13) ### Bug Fixes * **CHANGELOG:** update broken links ([4483b9f](https://github.com/webpack-contrib/schema-utils/commit/4483b9f)) * **package:** update broken links ([f2494ba](https://github.com/webpack-contrib/schema-utils/commit/f2494ba)) ## [0.4.4](https://github.com/webpack-contrib/schema-utils/compare/v0.4.3...v0.4.4) (2018-02-13) ### Bug Fixes * **package:** update `dependencies` ([#22](https://github.com/webpack-contrib/schema-utils/issues/22)) ([3aecac6](https://github.com/webpack-contrib/schema-utils/commit/3aecac6)) ## [0.4.3](https://github.com/webpack-contrib/schema-utils/compare/v0.4.2...v0.4.3) (2017-12-14) ### Bug Fixes * **validateOptions:** throw `err` instead of `process.exit(1)` ([#17](https://github.com/webpack-contrib/schema-utils/issues/17)) ([c595eda](https://github.com/webpack-contrib/schema-utils/commit/c595eda)) * **ValidationError:** never return `this` in the ctor ([#16](https://github.com/webpack-contrib/schema-utils/issues/16)) ([c723791](https://github.com/webpack-contrib/schema-utils/commit/c723791)) ## [0.4.2](https://github.com/webpack-contrib/schema-utils/compare/v0.4.1...v0.4.2) (2017-11-09) ### Bug Fixes * **validateOptions:** catch `ValidationError` and handle it internally ([#15](https://github.com/webpack-contrib/schema-utils/issues/15)) ([9c5ef5e](https://github.com/webpack-contrib/schema-utils/commit/9c5ef5e)) ## [0.4.1](https://github.com/webpack-contrib/schema-utils/compare/v0.4.0...v0.4.1) (2017-11-03) ### Bug Fixes * **ValidationError:** use `Error.captureStackTrace` for `err.stack` handling ([#14](https://github.com/webpack-contrib/schema-utils/issues/14)) ([a6fb974](https://github.com/webpack-contrib/schema-utils/commit/a6fb974)) # [0.4.0](https://github.com/webpack-contrib/schema-utils/compare/v0.3.0...v0.4.0) (2017-10-28) ### Features * add support for `typeof`, `instanceof` (`{Function\|RegExp}`) ([#10](https://github.com/webpack-contrib/schema-utils/issues/10)) ([9f01816](https://github.com/webpack-contrib/schema-utils/commit/9f01816)) # [0.3.0](https://github.com/webpack-contrib/schema-utils/compare/v0.2.1...v0.3.0) (2017-04-29) ### Features * add ValidationError ([#8](https://github.com/webpack-contrib/schema-utils/issues/8)) ([d48f0fb](https://github.com/webpack-contrib/schema-utils/commit/d48f0fb)) ## [0.2.1](https://github.com/webpack-contrib/schema-utils/compare/v0.2.0...v0.2.1) (2017-03-13) ### Bug Fixes * Include .babelrc to `files` ([28f0363](https://github.com/webpack-contrib/schema-utils/commit/28f0363)) * Include source to `files` ([43b0f2f](https://github.com/webpack-contrib/schema-utils/commit/43b0f2f)) # [0.2.0](https://github.com/webpack-contrib/schema-utils/compare/v0.1.0...v0.2.0) (2017-03-12) # 0.1.0 (2017-03-07) ### Features * **validations:** add validateOptions module ([ae9b47b](https://github.com/webpack-contrib/schema-utils/commit/ae9b47b)) # Change Log All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. schema-utils-1.0.0/LICENSE000066400000000000000000000020571333234445000151200ustar00rootroot00000000000000Copyright JS Foundation and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. schema-utils-1.0.0/README.md000066400000000000000000000056701333234445000153760ustar00rootroot00000000000000[![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] [![test][test]][test-url] [![coverage][cover]][cover-url] [![chat][chat]][chat-url]

Schema Utils

Install

```bash npm i schema-utils ```

Usage

### `validateOptions` **`schema.json`** ```js { "type": "object", "properties": { // Options... }, "additionalProperties": false } ``` #### Error Messages (Custom) **`schema.json`** ```js { "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 } ``` ```js import schema from 'path/to/schema.json' import validateOptions from 'schema-utils' validateOptions(schema, options, 'Loader/Plugin Name') ```

Examples

**schema.json** ```json { "type": "object", "properties": { "name": { "type": "string" }, "test": { "anyOf": [ { "type": "array" }, { "type": "string" }, { "instanceof": "RegExp" } ] }, "transform": { "instanceof": "Function" }, "sourceMap": { "type": "boolean" } }, "additionalProperties": false } ``` ### `Loader` ```js import { 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... } ``` ### `Plugin` ```js import 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... } } ``` [npm]: https://img.shields.io/npm/v/schema-utils.svg [npm-url]: https://npmjs.com/package/schema-utils [node]: https://img.shields.io/node/v/schema-utils.svg [node-url]: https://nodejs.org [deps]: https://david-dm.org/webpack-contrib/schema-utils.svg [deps-url]: https://david-dm.org/webpack-contrib/schema-utils [test]: http://img.shields.io/travis/webpack-contrib/schema-utils.svg [test-url]: https://travis-ci.org/webpack-contrib/schema-utils [cover]: https://codecov.io/gh/webpack-contrib/schema-utils/branch/master/graph/badge.svg [cover-url]: https://codecov.io/gh/webpack-contrib/schema-utils [chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg [chat-url]: https://gitter.im/webpack/webpack schema-utils-1.0.0/appveyor.yml000066400000000000000000000004661333234445000165050ustar00rootroot00000000000000init: - git config --global core.autocrlf input build: 'off' matrix: fast_finish: true environment: matrix: - nodejs_version: '10' - nodejs_version: '8' - nodejs_version: '6' install: - ps: Install-Product node $env:nodejs_version x64 - npm i -g npm - npm i test_script: - npm t schema-utils-1.0.0/commitlint.config.js000066400000000000000000000001071333234445000200660ustar00rootroot00000000000000module.exports = { extends: [ '@commitlint/config-conventional' ] }; schema-utils-1.0.0/docs/000077500000000000000000000000001333234445000150375ustar00rootroot00000000000000schema-utils-1.0.0/docs/logo.png000066400000000000000000000413731333234445000165150ustar00rootroot00000000000000PNG  IHDRX IDATx]ytEu'ݝȾB !H@ (\ "nO\1yrpˆ"MAȚHd%+:޾zxOwo>hu[u{%bH$B 'B1o6۲y[g/g[^;x7K΃?^A~wHVeG ¶}{=!CvR-:bnnnTg!;.헓ahZt:BMމ-,TTT@,C.T*D"R 69pw\CFRJJRĝ;wp^^^xz'ґQMM ֮]*w5jBBB0tPDFF"&&T*/g,|x i%eh4GOOQ]]Z(//Gss7iii& ,SIjM2j̙38sɳaaaEBB1|p" 6wg&jtvvUUUō7pAVd5V4x8v! ظq#@&!)) SNEZZ&LHab-Bd͎w58wJKKq)tuuM8ڧr$mT*ƌ3#GnnnF{ My( ա'NP[[~t|8|0ƏL4 Ǐǐ!Cx)+wg,|yڵk8y$PTTFF{g+ǎïdcT*`$}NCkk+:m۶ԩShkkk"@9-//GSSJKKddggo΅`J•+Wwaǎro=Dغu+l2̟?pww]Al0‘#Gi&/!ꫯaG*CܼysP)S^g3NiRWWmۆo===.+qiZ;v +WDMMܹs{6ۨB!jj* mmmy&QZZJwxx86mڄl:8g'8D9D2̤naMF*Zր `0 NJ^'Nw};wPÆ )) v'G M1N-[C__5Ř={6Ν'""">>>4TÉb~|Q`[{oM դaoҹ()-(J(,,7|Ce>r96l؀E8u! =Yo3HXX@3i$aRYYIV'k2k;su6aJ"?$cƌ2IIIt:55<=Kj O?4VZxxyyY,db썉3x (J(Jt:d2xyy6qWeHD,_/ɕ+WpA<6I:vQsM,8*++nC2 oUV!""0\<<ͅf;w%%%صk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XjN'tNK63+3gÃZVԑX[1IJݢqqqxg1c;ܐz 3gKXj/^L 9 8IRL8k׮NѣGNQFᩧ£> :}GnR'OGb/ ,E[e2e VXsI]8(8Dll,8w{Tp̞=4i]:W``///L<7n+jNƍ'|CttKѓD"All,.]#F`ӦM駟\;wΝy!33IDATX,?f̘HL<;wę3g}rAlHp:c-dNaŘ2e RRRd5H9pJHLLDDDL8pǎ0L&øqC!==IIIz`匕G$A,GNNʰ~߿---j-a3!!5ɓ`^.[ Lr8w\1ooo92e .]W{1ܣ(#8H̝;GFll,///d2q9 8&OOO#88P(xQ[[Jv>q\e̓OBy9cǎELL BBB#""T*?% ajVׇwAKK q%HKKùs~-٠v^^^777bլ0Ě~h~g KϲךsfΏaGV 66֪)Ȇ5Z􌵱C90MΐC^N:8Pb$n܆J=9lxF6+1N#S-N-Mf;.qIuτPWx?}ӈ)FpIENDB`schema-utils-1.0.0/package.json000066400000000000000000000023111333234445000163720ustar00rootroot00000000000000{ "name": "schema-utils", "version": "1.0.0", "description": "webpack Validation Utils", "main": "src/index.js", "files": [ "src" ], "engines": { "node": ">= 4" }, "scripts": { "lint": "eslint --cache src test", "test": "jest --env node --verbose --coverage", "clean": "del-cli coverage", "commits": "commitlint --from $(git rev-list --tags --max-count=1)", "release": "npm run commits && standard-version" }, "dependencies": { "ajv": "^6.1.0", "ajv-errors": "^1.0.0", "ajv-keywords": "^3.1.0" }, "devDependencies": { "@commitlint/cli": "^7.0.0", "@commitlint/config-conventional": "^7.0.0", "@webpack-contrib/eslint-config-webpack": "^2.0.0", "del-cli": "^1.0.0", "eslint": "^5.0.0", "eslint-plugin-import": "^2.0.0", "eslint-plugin-prettier": "^2.0.0", "jest": "^21.0.0", "prettier": "^1.0.0", "standard-version": "^4.0.0" }, "author": "webpack Contrib (https://github.com/webpack-contrib)", "bugs": "https://github.com/webpack-contrib/schema-utils/issues", "homepage": "https://github.com/webpack-contrib/schema-utils", "repository": "https://github.com/webpack-contrib/schema-utils", "license": "MIT" } schema-utils-1.0.0/src/000077500000000000000000000000001333234445000146765ustar00rootroot00000000000000schema-utils-1.0.0/src/ValidationError.js000066400000000000000000000010701333234445000203360ustar00rootroot00000000000000/* eslint-disable strict, no-param-reassign */ 'use strict'; class ValidationError extends Error { constructor(errors, name) { super(); this.name = 'ValidationError'; this.message = `${name || ''} Invalid Options\n\n`; this.errors = errors.map((err) => { err.dataPath = err.dataPath.replace(/\//g, '.'); return err; }); this.errors.forEach((err) => { this.message += `options${err.dataPath} ${err.message}\n`; }); Error.captureStackTrace(this, this.constructor); } } module.exports = ValidationError; schema-utils-1.0.0/src/index.js000066400000000000000000000002071333234445000163420ustar00rootroot00000000000000/* eslint-disable strict */ 'use strict'; const validateOptions = require('./validateOptions'); module.exports = validateOptions; schema-utils-1.0.0/src/validateOptions.js000066400000000000000000000013511333234445000204010ustar00rootroot00000000000000/* eslint-disable strict, no-param-reassign */ 'use strict'; const fs = require('fs'); const path = require('path'); const Ajv = require('ajv'); const errors = require('ajv-errors'); const keywords = require('ajv-keywords'); const ValidationError = require('./ValidationError'); const ajv = new Ajv({ allErrors: true, jsonPointers: true, }); errors(ajv); keywords(ajv, ['instanceof', 'typeof']); const validateOptions = (schema, options, name) => { if (typeof schema === 'string') { schema = fs.readFileSync(path.resolve(schema), 'utf8'); schema = JSON.parse(schema); } if (!ajv.validate(schema, options)) { throw new ValidationError(ajv.errors, name); } return true; }; module.exports = validateOptions; schema-utils-1.0.0/test/000077500000000000000000000000001333234445000150665ustar00rootroot00000000000000schema-utils-1.0.0/test/__snapshots__/000077500000000000000000000000001333234445000177045ustar00rootroot00000000000000schema-utils-1.0.0/test/__snapshots__/index.test.js.snap000066400000000000000000000056631333234445000233010ustar00rootroot00000000000000// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Error Errors 1`] = ` Array [ Object { "dataPath": ".string", "keyword": "type", "message": "should be string", "params": Object { "type": "string", }, "schemaPath": "#/properties/string/type", }, Object { "dataPath": ".array", "keyword": "type", "message": "should be array", "params": Object { "type": "array", }, "schemaPath": "#/properties/array/type", }, Object { "dataPath": ".object.prop", "keyword": "type", "message": "should be boolean", "params": Object { "type": "boolean", }, "schemaPath": "#/properties/object/properties/prop/type", }, Object { "dataPath": ".object.object.prop", "keyword": "type", "message": "should be boolean", "params": Object { "type": "boolean", }, "schemaPath": "#/properties/object/properties/object/properties/prop/type", }, Object { "dataPath": ".boolean", "keyword": "type", "message": "should be boolean", "params": Object { "type": "boolean", }, "schemaPath": "#/properties/boolean/type", }, Object { "dataPath": ".type", "keyword": "typeof", "message": "should pass \\"typeof\\" keyword validation", "params": Object { "keyword": "typeof", }, "schemaPath": "#/properties/type/typeof", }, Object { "dataPath": ".instance", "keyword": "instanceof", "message": "should pass \\"instanceof\\" keyword validation", "params": Object { "keyword": "instanceof", }, "schemaPath": "#/properties/instance/instanceof", }, ] `; exports[`Error Messages Customized 1`] = ` Object { "dataPath": ".string", "keyword": "errorMessage", "message": "should be {String} (https://github.com/org/repo#anchor)", "params": Object { "errors": Array [ Object { "dataPath": "/string", "keyword": "type", "message": "should be string", "params": Object { "type": "string", }, "schemaPath": "#/properties/string/type", }, ], }, "schemaPath": "#/errorMessage", } `; exports[`Error Messages Customized 2`] = ` "{Name} Invalid Options options.string should be {String} (https://github.com/org/repo#anchor) " `; exports[`Error Messages Default 1`] = ` Object { "dataPath": ".string", "keyword": "type", "message": "should be string", "params": Object { "type": "string", }, "schemaPath": "#/properties/string/type", } `; exports[`Error Messages Default 2`] = ` "{Name} Invalid Options options.string should be string " `; exports[`Error Throws 1`] = ` "{Name} Invalid Options options.string should be string options.array should be array options.object.prop should be boolean options.object.object.prop should be boolean options.boolean should be boolean options.type should pass \\"typeof\\" keyword validation options.instance should pass \\"instanceof\\" keyword validation " `; schema-utils-1.0.0/test/fixtures/000077500000000000000000000000001333234445000167375ustar00rootroot00000000000000schema-utils-1.0.0/test/fixtures/errors/000077500000000000000000000000001333234445000202535ustar00rootroot00000000000000schema-utils-1.0.0/test/fixtures/errors/schema.json000066400000000000000000000030241333234445000224050ustar00rootroot00000000000000{ "type": "object", "properties": { "string": { "type": "string" }, "array": { "type": "array", "items": { "type": "string" } }, "object": { "type": "object", "properties": { "prop": { "type": "boolean" }, "object": { "type": "object", "properties": { "prop": { "type": "boolean" } }, "errorMessage": { "properties": { "prop": "should be {Boolean} (https://github.com/org/repo#anchor)" } } } }, "errorMessage": { "properties": { "prop": "should be {Boolean} (https://github.com/org/repo#anchor)", "object": "should be {Object} (https://github.com/org/repo#anchor)" } } }, "boolean": { "type": "boolean" }, "type": { "typeof": "function" }, "instance": { "instanceof": "RegExp" } }, "errorMessage": { "properties": { "type": "should be {Function} (https://github.com/org/repo#anchor)", "array": "should be {Array} (https://github.com/org/repo#anchor)", "string": "should be {String} (https://github.com/org/repo#anchor)", "object": "should be {Object} (https://github.com/org/repo#anchor)", "boolean": "should be {Boolean} (https://github.com/org/repo#anchor)", "instance": "should be {RegExp} (https://github.com/org/repo#anchor)" } }, "additionalProperties": false } schema-utils-1.0.0/test/fixtures/schema.json000066400000000000000000000012331333234445000210710ustar00rootroot00000000000000{ "type": "object", "properties": { "string": { "type": "string" }, "array": { "type": "array", "items": { "type": "string" } }, "object": { "type": "object", "properties": { "prop": { "type": "boolean" }, "object": { "type": "object", "properties": { "prop": { "type": "boolean" } } } } }, "boolean": { "type": "boolean" }, "type": { "typeof": "function" }, "instance": { "instanceof": "RegExp" } }, "additionalProperties": false } schema-utils-1.0.0/test/index.test.js000066400000000000000000000051461333234445000175170ustar00rootroot00000000000000/* eslint-disable strict, no-shadow, arrow-body-style */ 'use strict'; const validateOptions = require('../src'); test('Valid', () => { const options = { type() {}, array: ['a'], string: 'hello', object: { prop: false, object: { prop: false, }, }, boolean: true, instance: new RegExp(''), }; const validate = () => { return validateOptions('test/fixtures/schema.json', options, '{Name}'); }; expect(validate()).toBe(true); }); describe('Error', () => { const options = { type: null, array: {}, string: false, object: { prop: 1, object: { prop: 1, }, }, boolean: 'hello', instance() {}, }; const validate = () => { return validateOptions('test/fixtures/schema.json', options, '{Name}'); }; test('Throws', () => { expect(validate).toThrowError(); expect(validate).toThrowErrorMatchingSnapshot(); }); test('Errors', () => { try { validate(); } catch (err) { const errors = err.errors.map((err) => err.dataPath); const expected = [ '.string', '.array', '.object.prop', '.object.object.prop', '.boolean', '.type', '.instance', ]; expect(errors).toMatchObject(expected); expect(err.errors).toMatchSnapshot(); } }); describe('Messages', () => { test('Default', () => { const options = { type() {}, array: [''], string: 1, object: { prop: false, object: { prop: false, }, }, boolean: true, instance: new RegExp(''), }; const validate = () => { return validateOptions('test/fixtures/schema.json', options, '{Name}'); }; try { validate(); } catch (err) { err.errors.forEach((err) => expect(err).toMatchSnapshot()); expect(err.message).toMatchSnapshot(); } }); test('Customized', () => { const options = { type() {}, array: [''], string: 1, object: { prop: false, object: { prop: false, }, }, boolean: true, instance: new RegExp(''), }; const validate = () => { return validateOptions( 'test/fixtures/errors/schema.json', options, '{Name}' ); }; try { validate(); } catch (err) { err.errors.forEach((err) => expect(err).toMatchSnapshot()); expect(err.message).toMatchSnapshot(); } }); }); });