{"id":25609080,"url":"https://github.com/timbeadle/grunt-tv4","last_synced_at":"2025-04-13T13:24:58.685Z","repository":{"id":38375769,"uuid":"10654847","full_name":"timbeadle/grunt-tv4","owner":"timbeadle","description":"Use Grunt and Tiny Validator tv4 to validate files against json-schema draft v4","archived":false,"fork":false,"pushed_at":"2025-03-19T09:39:11.000Z","size":4721,"stargazers_count":13,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T19:27:23.460Z","etag":null,"topics":["grunt","grunt-plugins","json-schema","needs-maintainer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timbeadle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-12T23:40:35.000Z","updated_at":"2025-03-19T09:39:15.000Z","dependencies_parsed_at":"2023-10-03T18:45:32.458Z","dependency_job_id":"cf165216-26d7-4017-96e5-723e2ff352b8","html_url":"https://github.com/timbeadle/grunt-tv4","commit_stats":{"total_commits":761,"total_committers":14,"mean_commits":"54.357142857142854","dds":0.5847568988173456,"last_synced_commit":"32a2d0c3c324234f77fc035c782126dbc7323af3"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbeadle%2Fgrunt-tv4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbeadle%2Fgrunt-tv4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbeadle%2Fgrunt-tv4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbeadle%2Fgrunt-tv4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timbeadle","download_url":"https://codeload.github.com/timbeadle/grunt-tv4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248719074,"owners_count":21150685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grunt","grunt-plugins","json-schema","needs-maintainer"],"created_at":"2025-02-21T20:31:42.976Z","updated_at":"2025-04-13T13:24:58.652Z","avatar_url":"https://github.com/timbeadle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-tv4\n\n[![npm version](https://img.shields.io/npm/v/grunt-tv4.svg)](https://www.npmjs.com/package/grunt-tv4)\n[![Downloads/month](https://img.shields.io/npm/dm/grunt-tv4.svg)](https://www.npmjs.com/package/grunt-tv4)\n[![Build Status](https://github.com/timbeadle/grunt-tv4/workflows/Node.js%20CI/badge.svg)](https://github.com/timbeadle/grunt-tv4)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)\n[![Code Climate](https://codeclimate.com/github/timbeadle/grunt-tv4/badges/gpa.svg)](https://codeclimate.com/github/timbeadle/grunt-tv4)\n[![DepShield Badge](https://depshield.sonatype.org/badges/timbeadle/grunt-tv4/depshield.svg)](https://depshield.github.io)\n[![Known Vulnerabilities](https://snyk.io/test/github/timbeadle/grunt-tv4/badge.svg)](https://snyk.io/test/github/timbeadle/grunt-tv4)\n\n\u003e Use grunt and [Tiny Validator tv4](https://github.com/geraintluff/tv4) to validate values against [json-schema](http://json-schema.org/) draft v4\n\n## Getting Started\n\nThis plugin requires Grunt `\u003e=1.5.0`\n\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:\n\n```shell\n$ npm install grunt-tv4 --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-tv4');\n```\n\n## The \"tv4\" task\n\n### Notes\n\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).\n* Supports automatically resolution and loading remote references by http via `$ref`.\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).\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).\n* Errors formatted by the [tv4-reporter](https://github.com/Bartvds/tv4-reporter) library.\n\n### API change\n\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/timbeadle/grunt-tv4/tree/71ef1726945d05efd5daca29f26cbf4ab09c858e).\n\nThe root schema must now to be specified as `options.root`.\n\n### Example\n\n* Demo of version `v0.3.0` output on [travis-ci](https://travis-ci.org/timbeadle/grunt-tv4/jobs/14468920)\n\n### Basic usage\n\nValidate from .json files:\n\n```js\ngrunt.initConfig({\n\ttv4: {\n\t\toptions: {\n\t\t    root: grunt.file.readJSON('schema/main.json')\n\t\t},\n\t\tmyTarget: {\n\t\t\tsrc: ['data/*.json']\n\t\t}\n\t}\n})\n```\n\nValdiate values:\n\n```js\ngrunt.initConfig({\n\ttv4: {\n\t\tmyTarget: {\n\t\t\toptions: {\n\t\t\t\troot: {\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tproperties: { ... }\n\t\t\t\t}\n\t\t\t},\n\t\t\tvalues: [\n\t\t\t\t{ ... },\n\t\t\t\t{ ... }\n\t\t\t]\n\t\t}\n\t}\n})\n````\n\n### Advanced usage\n\n```js\ngrunt.initConfig({\n\ttv4: {\n\t\toptions: {\n\t\t\t// specify the main schema, one of:\n            // - path to json\n            // - http-url\n            // - schema object\n            // - callback that returns one of the above\n\t\t\troot: grunt.file.readJSON('schema/main.json'),\n\n\t\t\t// show multiple errors per file (off by default)\n\t\t\tmulti: true,\n\n\t\t\t// create a new tv4 instance for every target (off by default)\n\t\t\tfresh: true,\n\n\t\t\t// add schemas in bulk (each required to have an 'id' property) (can be a callback)\n\t\t\tadd: [\n\t\t\t\t grunt.file.readJSON('schema/apple.json'),\n\t\t\t\t grunt.file.readJSON('schema/pear.json')\n\t\t\t],\n\n\t\t\t// set schemas by URI (can be a callback)\n\t\t\tschemas: {\n\t\t\t\t'http://example.com/schema/apple': grunt.file.readJSON('schema/apple.json'),\n\t\t\t\t'http://example.com/schema/pear': grunt.file.readJSON('schema/pear.json')\n\t\t\t},\n\n\t\t\t// map of custom formats passed to tv4.addFormat()\n\t\t\tformats: {\n\t\t\t\tdate: function (data, schema) {\n\t\t\t\t\tif (typeof data !== 'string' || !dateRegex.test(data)) {\n\t\t\t\t\t\treturn 'value must be string of the form: YYYY-MM-DD';\n\t\t\t\t\t}\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// passed to tv4.validate()\n\t\t\tcheckRecursive: false,\n\t\t\t// passed to tv4.validate()\n\t\t\tbanUnknownProperties: false,\n\t\t\t// passed tv4.language()\n\t\t\tlanguage: 'de',\n\t\t\t// passed tv4.addLanguage()\n\t\t\tlanguages: {\n\t\t\t\t'de': { ... }\n\t\t\t}\n\t\t},\n\t\t// load json from disk\n\t\tmyFiles: {\n\t\t\tsrc: ['data/*.json', 'data/fruit/**/*.json']\n\t\t},\n\n\t\tmyValues: {\n\t\t\t// validate values\n\t\t\tvalues: [\n\t\t\t\tgrunt.file.readJSON('data/apple.json'),\n\t\t\t\tgrunt.file.readJSON('data/pear.json')\n\t\t\t],\n\t\t},\n\n\t\tmyValueMap: {\n\t\t\t// alternately pass as object and the keys will be used as labels in the reports\n\t\t\tvalues: {\n\t\t\t\t'apple': grunt.file.readJSON('data/apple.json'),\n\t\t\t\t'pear': grunt.file.readJSON('data/pear.json')\n\t\t\t},\n\t\t},\n\n\t\tmyCallback: {\n\t\t\t// alternately pass a function() to return a collection of values (array or object)\n\t\t\tvalues: function() {\n\t\t\t\treturn {\n\t\t\t\t\t'apple': grunt.file.readJSON('data/apple.json'),\n\t\t\t\t\t'pear': grunt.file.readJSON('data/pear.json')\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n})\n```\n\n## History\n\n* See [CHANGELOG](https://github.com/timbeadle/grunt-tv4/blob/main/CHANGELOG.md).\n\n## Contributing\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/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimbeadle%2Fgrunt-tv4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimbeadle%2Fgrunt-tv4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimbeadle%2Fgrunt-tv4/lists"}