Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tv4-reporter

timbeadle4667.1.0

Report Tiny Validator tv4 results in usable formats

tv4, format, reporter, json-schema

readme

tv4-reporter

npm version Downloads/month Build Status XO code style Code Climate DepShield Badge Known Vulnerabilities

Reporters to display usable Tiny Validator tv4 output of json-schema validation.

This module is used by various dependents to render tv4 validation result objects in a compact but highly readable (and possibly colourful) format. Functionality is tuned for both CLI output as well as plain-text or pre-formatted HTML/CSS.

Note: at this point this is not a 'validator' or 'test runner', nor is it a finished application. It is a library to use as dependency in tv4 based testers. Use plain tv4 and pass the result(s) to one of tv4-reporters helpers. If you are looking for a validator see one of the implementing tv4 wrappers for convenience (some linked below).

Features

  • Indented, tree-like display.
  • Single and multiple errors.
  • Optionally display summaries.
  • Recursive sub-errors (as generated by anyOf, oneOf etc).
  • Missing sub-schemas (optionally report as fail or pass reason).
  • Various output writer/coloriser modes using ministyle and miniwrite.

Examples

(possibly outdated)

  1. Examples of many different kind of errors in this Travis-Ci build.
  2. Bulk reporter with single error:

    WebStorm example

Installation

$ npm install tv4-reporter --save-dev

Usage

Still very-much in flux so possibly outdated examples.

Minimal use case (likely this is spread over the implementing application):

// assemble the components
var tv4 = require('tv4');
var out = require('miniwrite').console();
var style = require('ministyle').ansi();
var reporter = require('tv4-reporter').getReporter(out, style);

// now validate
var result = tv4.validateMultiple(myValue, mySchema);
if (!result.valid || result.missing.length > 0) {
    // get data object (might get these in bulk/async from somewhere)
    var res = reporter.createTest(mySchema, myValue, 'my special test', true);

    // report error
    reporter.reportResult(res);

    // if you have a many results you can use bulk to print nicely with summaries
    reporter.reportBulk([res, res2, res3], [pass1, pass2]);

    // only totals
    reporter.reportTotals(3, 4);
}

Bulk reporting:

// if you have a many results you can use bulk to print nicely with summaries
reporter.reportBulk([res, res2, res3], [pass1, pass2]);

// only totals
reporter.reportTotals(3, 4);

For more API surface like (partial) reporter and various helpers see the exports in the main module. Also see the 'known dependants' for more examples.

Output

Report output and styling done via extensible mini-api's:

  • ministyle (bundled with plain, ansi, html/css etc + utils)
  • miniwrite (bundled with streaming console.log, line buffer, node-streams etc + utils)

Known dependents

  • grunt-tv4 (bulk validator with http lookup for grunt)
  • chai-json-schema (assertion wrappers) (update in progress)
  • (planned) a commandline validator (cued for extraction from grunt-tv4)
  • (planned) a json-schema assert()-ion (chai-json-schema without chai)

Future

  1. Output will likely be tuned over time.
  2. Current version is very functional but doesn't yet do anything specific for each validation rule type.

Release support matrix

Release Min Node ver. Support
1.x 4.0.0 Obsolete
2.x 8.0.0 Obsolete
3.x 8.0.0 Obsolete
4.x 10.0.0 Obsolete
5.x 12.0.0 Security
6.x 14.0.0 Current

Release history

Build

Nothing much here as the code is still being extracted from the original projects.

Install development dependencies in your git checkout:

$ npm install

Build and run tests:

$ grunt

See the Gruntfile.js for additional commands.

Contributing

In 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.

Note: this is an opinionated module: please create a ticket to discuss any big ideas. Pull requests for bug fixes are of course always welcome.

License

Copyright (c) 2013 Bart van der Schoor

Licensed under the MIT license.

changelog

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

7.1.0 - 2024-03-05

Added

  • versioning-strategy: increase in dependabot.yml
  • packageRules, rangeStrategy, transitiveRemediation in renovate.json

Updated

7.0.0 - 2023-09-28

Updated

Removed

  • NodeJS v14 test runs

6.0.0 - 2023-09-22

Updated

5.0.2 - 2023-07-07

Added

  • (README) Release support matrix
  • Node 12.0.x, 14.0.x, 14.13.x, 14.17.x, 20.x test runs
  • Volta pin node@12.0.0, npm@7.24.2
  • Renovate baseBranches config

Updated

Removed

  • Node 19.x test run

5.0.1 - 2023-03-10

Added

Removed

  • jsonpointer.js

5.0.0 - 2022-11-20

Added

  • Renovate & Dependabot for dependency management
  • ESLint (with xo config)
  • Github action for testing
  • NodeJS v19 test run

Updated

  • Source code to adhere to xo code style
  • Minimum NodeJS version now v12
  • actions/checkout@v3
  • actions/setup-node@v3
  • github/codeql-action/init@v2
  • github/codeql-action/autobuild@v2
  • github/codeql-action/analyze@v2

Removed

  • NodeJS v10 support
  • xo
  • DavidDM (dependency analysis)
  • TravisCI testing
  • NodeJS v10, v13, v15 test runs

4.3.0 - 2020-11-20

Added

  • codeql analysis

Updated

4.2.0 - 2020-10-21

Added

  • nodejs v15 support

Updated

4.1.0 - 2020-07-07

Added

  • nodejs v14 support
  • travis-ci.com for test/build

Updated

Removed

  • Greenkeeper badge (retired)
  • travis-ci.org for test/build

4.0.2 - 2020-03-19

Updated

4.0.1 - 2020-03-18

Updated

  • Upgrade minimist to remove security vulnerabilty

4.0.0 - 2020-03-05

Added

  • Github actions for running tests, via test:ci npm script

Updated

Removed

  • nodejs <10 support

3.0.0 - 2020-01-27

Added

  • .prettierrc.yaml
  • nodejs v13 support in .travis.yml
  • xo linter

Updated

  • Refactored lib/reporter.js to conform to xo linting rules and use es6 arrow functions
  • Abstracted utils into separate lib/utils.js module
  • prettier@1.19.1
  • snyk@1.283.0

Removed

  • eslint and plugins/config

2.0.3 - 2019-10-13

Updated

2.0.2 - 2019-09-07

Added

  • Greenkeeper.io badge

Updated

Removed

  • Bitdeli.com badge (defunct)

2.0.1 - 2019-07-11

Added

  • snyk protect

Updated

2.0.0 - 2019-05-26

Added

  • node 12 support
  • DepShield & Snyk badges

Updated

Removed

  • preinstall of grunt-cli (unneeded)
  • node 6, 7 support

1.1.0 - 2019-02-10

Added

  • .editorconfig
  • Snyk monitoring
  • node 8, 9, 10, 11 support in .travis.yml
  • eslint
  • eslint-{config,plugin}-prettier

Updated

Removed

  • node 4, 5 support
  • grunt and plugins

1.0.0 - 2016-11-06

Added

  • node v7 support in .travis.yml
  • Changelog (this file)

Updated

Removed

  • node v0.10 support in .travis.yml

0.1.1 - 2016-04-08

Added

  • Add Code Climate & Download/month badges

Updated

  • other README tweaks

0.1.0 - 2016-04-08

Added

  • node 4 & 5 support
  • grunt-release-it for easier release management

Updated

  • docs changed to reflect new project ownership
  • Various dependencies, including grunt@1.0.1

Removed

  • node 0.8 support

0.0.4 - 2014-02-16

Added

  • various fixes

0.0.3 2013-11-28

Added

  • added a toStrim() for schemaValue no [object Object]

0.0.2 2013-11-28

Added

  • tv4 as a peerDependency
  • /media to .gitignore

0.0.1 2013-11-28

Updated

  • tuned module
    • moved some helpers
    • split reportTotals from reportBulk
    • added separators
  • expanded README.md
    • added usage example
    • added links
    • tuned text
  • added miniwrite/ministyle as peer dependencies to package.json