1 | { |
---|
2 | "name": "grunt-tv4", |
---|
3 | "description": "Validate values against json-schema v4", |
---|
4 | "version": "0.4.0", |
---|
5 | "homepage": "https://github.com/Bartvds/grunt-tv4", |
---|
6 | "author": { |
---|
7 | "name": "Bart van der Schoor", |
---|
8 | "url": "https://github.com/Bartvds" |
---|
9 | }, |
---|
10 | "repository": { |
---|
11 | "type": "git", |
---|
12 | "url": "https://github.com/Bartvds/grunt-tv4" |
---|
13 | }, |
---|
14 | "bugs": { |
---|
15 | "url": "https://github.com/Bartvds/grunt-tv4/issues" |
---|
16 | }, |
---|
17 | "licenses": [ |
---|
18 | { |
---|
19 | "type": "MIT", |
---|
20 | "url": "https://github.com/Bartvds/grunt-tv4/blob/master/LICENSE-MIT" |
---|
21 | } |
---|
22 | ], |
---|
23 | "keywords": [ |
---|
24 | "gruntplugin", |
---|
25 | "validate", |
---|
26 | "validator", |
---|
27 | "json", |
---|
28 | "schema", |
---|
29 | "json-schema", |
---|
30 | "tv4" |
---|
31 | ], |
---|
32 | "main": "Gruntfile.js", |
---|
33 | "engines": { |
---|
34 | "node": ">= 0.10.0" |
---|
35 | }, |
---|
36 | "scripts": { |
---|
37 | "test": "grunt test" |
---|
38 | }, |
---|
39 | "dependencies": { |
---|
40 | "jsonpointer.js": "0.3.0", |
---|
41 | "request": "2.25.0", |
---|
42 | "tv4": "~1.0.14", |
---|
43 | "ministyle": "~0.1.0", |
---|
44 | "miniwrite": "~0.1.0", |
---|
45 | "tv4-reporter": "~0.0.3" |
---|
46 | }, |
---|
47 | "devDependencies": { |
---|
48 | "grunt-cli": "~0.1", |
---|
49 | "grunt": "~0.4.1", |
---|
50 | "grunt-contrib-connect": "~0.3.0", |
---|
51 | "grunt-continue": "0.0.1", |
---|
52 | "grunt-contrib-jshint": "~0.7.2", |
---|
53 | "jshint-path-reporter": "~0.1.3", |
---|
54 | "package.json-schema": "~0.1.2", |
---|
55 | "request": "^2.25.0" |
---|
56 | }, |
---|
57 | "peerDependencies": { |
---|
58 | "grunt": "~0.4.1" |
---|
59 | }, |
---|
60 | "readme": "# grunt-tv4\r\n\r\n[](http://travis-ci.org/Bartvds/grunt-tv4) [](https://gemnasium.com/Bartvds/grunt-tv4) [](http://badge.fury.io/js/grunt-tv4)\r\n\r\n> Use grunt and [Tiny Validator tv4](https://github.com/geraintluff/tv4) to validate values against [json-schema](http://json-schema.org/) draft v4\r\n\r\n## Getting Started\r\n\r\nThis plugin requires Grunt `~0.4.1`\r\n\r\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\r\n\r\n```shell\r\n$ npm install grunt-tv4 --save-dev\r\n```\r\n\r\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\r\n\r\n```js\r\ngrunt.loadNpmTasks('grunt-tv4');\r\n```\r\n\r\n## The \"tv4\" task\r\n\r\n### Notes\r\n\r\n* Uses [Tiny Validator tv4 ](https://github.com/geraintluff/tv4) so schemas must conform to [json-schema draft v4](http://json-schema.org/documentation.html).\r\n* Supports automatically resolution and loading remote references by http via `$ref`. \r\n* To use `$ref` see the [json-schema](http://json-schema.org/) documentation or [this help](http://spacetelescope.github.io/understanding-json-schema/structuring.html). \r\n* For general help with json-schema see this excelent [guide](http://spacetelescope.github.io/understanding-json-schema/) and usable [reference](http://spacetelescope.github.io/understanding-json-schema/reference/index.html).\r\n* Errors formatted by the [tv4-reporter](https://github.com/Bartvds/tv4-reporter) library.\r\n\r\n### API change \r\n\r\nAs of version `v0.2.0` the API was changed to follow the Grunt options- and file-selection conventions. The old pattern (which abused the destination-specifier) is no longer supported. The readme for the previous API can be found [here](https://github.com/Bartvds/grunt-tv4/tree/71ef1726945d05efd5daca29f26cbf4ab09c858e).\r\n\r\nThe root schema must now to be specified as `options.root`.\r\n\r\n### Example\r\n\r\n* Demo of version `v0.3.0` output on [travis-ci](https://travis-ci.org/Bartvds/grunt-tv4/jobs/14468920)\r\n\r\n### Basic usage\r\n\r\nValidate from .json files:\r\n\r\n```js\r\ngrunt.initConfig({\r\n\ttv4: {\r\n\t\toptions: {\r\n\t\t root: grunt.file.readJSON('schema/main.json')\r\n\t\t}\r\n\t\tmyTarget: {\r\n\t\t\tsrc: ['data/*.json']\r\n\t\t}\r\n\t}\r\n})\r\n```\r\n\r\nValdiate values:\r\n\r\n```js\r\ngrunt.initConfig({\r\n\ttv4: {\r\n\t\tmyTarget: {\r\n\t\t\toptions: {\r\n\t\t\t\troot: {\r\n\t\t\t\t\ttype: 'object',\r\n\t\t\t\t\tproperties: { ... }\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tvalues: [\r\n\t\t\t\t{ ... },\r\n\t\t\t\t{ ... }\r\n\t\t\t]\r\n\t\t}\r\n\t}\r\n})\r\n````\r\n\r\n### Advanced usage\r\n\r\n```js\r\ngrunt.initConfig({\r\n\ttv4: {\r\n\t\toptions: {\r\n\t\t\t// specify the main schema, one of:\r\n // - path to json\r\n // - http-url\r\n // - schema object\r\n // - callback that returns one of the above\r\n\t\t\troot: grunt.file.readJSON('schema/main.json'),\r\n\r\n\t\t\t// show multiple errors per file (off by default)\r\n\t\t\tmulti: true,\r\n\r\n\t\t\t// create a new tv4 instance for every target (off by default)\r\n\t\t\tfresh: true,\r\n\r\n\t\t\t// add schemas in bulk (each required to have an 'id' property) (can be a callback)\r\n\t\t\tadd: [\r\n\t\t\t\t grunt.file.readJSON('schema/apple.json'),\r\n\t\t\t\t grunt.file.readJSON('schema/pear.json')\r\n\t\t\t],\r\n\r\n\t\t\t// set schemas by URI (can be a callback)\r\n\t\t\tschemas: {\r\n\t\t\t\t'http://example.com/schema/apple': grunt.file.readJSON('schema/apple.json'),\r\n\t\t\t\t'http://example.com/schema/pear': grunt.file.readJSON('schema/pear.json')\r\n\t\t\t},\r\n\r\n\t\t\t// map of custom formats passed to tv4.addFormat()\r\n\t\t\tformats: {\r\n\t\t\t\tdate: function (data, schema) {\r\n\t\t\t\t\tif (typeof data !== 'string' || !dateRegex.test(data)) {\r\n\t\t\t\t\t\treturn 'value must be string of the form: YYYY-MM-DD';\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t}\r\n\t\t\t},\r\n\r\n\t\t\t// passed to tv4.validate()\r\n\t\t\tcheckRecursive: false\r\n\t\t\t// passed to tv4.validate()\r\n\t\t\tbanUnknownProperties: false\r\n\t\t\t// passed tv4.language()\r\n\t\t\tlanguage: 'de'\r\n\t\t\t// passed tv4.addLanguage()\r\n\t\t\tlanguages: {\r\n\t\t\t\t'de': { ... }\r\n\t\t\t}\r\n\t\t},\r\n\t\t// load json from disk\r\n\t\tmyFiles: {\r\n\t\t\tsrc: ['data/*.json', 'data/fruit/**/*.json']\r\n\t\t},\r\n\r\n\t\tmyValues: {\r\n\t\t\t// validate values\r\n\t\t\tvalues: [\r\n\t\t\t\tgrunt.file.readJSON('data/apple.json'),\r\n\t\t\t\tgrunt.file.readJSON('data/pear.json')\r\n\t\t\t],\r\n\t\t},\r\n\r\n\t\tmyValueMap: {\r\n\t\t\t// alternately pass as object and the keys will be used as labels in the reports\r\n\t\t\tvalues: {\r\n\t\t\t\t'apple': grunt.file.readJSON('data/apple.json'),\r\n\t\t\t\t'pear': grunt.file.readJSON('data/pear.json')\r\n\t\t\t},\r\n\t\t},\r\n\r\n\t\tmyCallback: {\r\n\t\t\t// alternately pass a function() to return a collection of values (array or object)\r\n\t\t\tvalues: function() {\r\n\t\t\t\treturn {\r\n\t\t\t\t\t'apple': grunt.file.readJSON('data/apple.json'),\r\n\t\t\t\t\t'pear': grunt.file.readJSON('data/pear.json')\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n})\r\n```\r\n\r\n## History\r\n\r\n* 0.4.0 - Updated some depedencies. `root`, `add` and `schemas` can be a callback function (for lazy init).\r\n* 0.3.0 - Big internal rewrite:\r\n\t* Added `.values` option. \r\n\t* Extracted reporting to [tv4-reporter](https://github.com/Bartvds/tv4-reporter), [miniwrite](https://github.com/Bartvds/miniwrite) and [ministyle](https://github.com/Bartvds/ministyle).\r\n\t* Moved loader logic to own stand-alone module (for later extraction)\r\n\t* Extracted test-running logic to own module (for later extraction)\r\n* 0.2.1 - Added support to report subErrors (for anyOf/oneOf)\r\n* 0.2.0 - Updated to follow the Grunt conventions.\r\n* 0.1.4 - Updated `tv4` to version `1.0.11` \r\n * Added support for `tv4.addFormat()` / `languages` / `checkRecursive` / `banUnknownProperties`.\r\n* 0.1.3 - Support for loading remote references (JSON Schema's `$ref`).\r\n* 0.1.1 - Bugfixes and improved reporting\r\n* 0.1.0 - First release with synchronous validation\r\n\r\n\r\n## Contributing\r\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\r\n\r\n\r\n[](https://bitdeli.com/free \"Bitdeli Badge\")\r\n\r\n", |
---|
61 | "readmeFilename": "README.md", |
---|
62 | "_id": "grunt-tv4@0.4.0", |
---|
63 | "dist": { |
---|
64 | "shasum": "2b6e01be443cffeb8654e47bf2fa64f7c65fdd0b" |
---|
65 | }, |
---|
66 | "_from": "grunt-tv4@", |
---|
67 | "_resolved": "https://registry.npmjs.org/grunt-tv4/-/grunt-tv4-0.4.0.tgz" |
---|
68 | } |
---|