tv4-reporter
Report Tiny Validator tv4 results in usable formats
Last updated 2 years ago by t1mmyb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install tv4-reporter 
SYNC missed versions from official npm registry.

tv4-reporter

npm version Downloads/month Build Status Dependency Status devDependency Status 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.

History

  • 0.1.1
    • Add Code Climate & Download/month badges and other README tweaks
  • 0.1.0
  • <= 0.0.4 - Many fixes and tweaks.
  • 0.0.1 - Extracted formatting code from grunt-tv4 and chai-json-schema.

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.

Current Tags

  • 7.1.0                                ...           latest (10 months ago)
  • 4.3.3                                ...           latest-4x (a year ago)
  • 5.0.3                                ...           latest-5x (a year ago)
  • 6.1.0                                ...           latest-6x (10 months ago)

30 Versions

  • 6.1.0                                ...           10 months ago
  • 7.1.0                                ...           10 months ago
  • 5.0.3                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 4.3.3                                ...           a year ago
  • 5.0.2                                ...           a year ago
  • 4.3.2                                ...           a year ago
  • 4.3.1                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.3.0                                ...           4 years ago
  • 4.2.0                                ...           4 years ago
  • 4.1.0                                ...           4 years ago
  • 4.0.2                                ...           5 years ago
  • 4.0.1                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.0.3                                ...           5 years ago
  • 2.0.2                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.4                                ...           11 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           11 years ago
  • 0.0.1                                ...           11 years ago
Maintainers (2)
Downloads
Total 2
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (6)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE