Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including sirenlint with all npm packages installed. Try it out:

var sirenlint = require("sirenlint")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

sirenlint v0.5.0

A lint tool for validating Siren (http://sirenspec.org).

sirenlint

A lint tool for validating Siren (http://sirenspec.org).

Build Status

Usage

CLI

$ sirenlint <siren-file>

or

$ cat <siren-file> | sirenlint

Example

$ echo '{ "links": [ { "rel": ["edit"] } ] }' | sirenlint
{ "links": [ { "rel": ["edit"] } ] }


sirenlint: 2 problems were found

error: ["links",0], Link is missing `href` attribute
warning: ["links"], The main entity is missing a link with a `self` relation

Output

The sirenlint command will output the original input followed by a summary of errors and/or warnings.
The summary includes a stringified JSON array defining the JSON path of the associated error or warning and a readable description of the problem.

Library

var fs = require('fs');
var path = require('path');
var validate = require('sirenlint');

var FILENAME = path.join(__dirname, '..', 'example', 'test.json');

var subject = fs.readFileSync(FILENAME);

var results = validate(subject);

results.forEach(function(r) {
  if (r instanceof validate.ValidationWarning) {
    console.log('WARNING:', r);
  } else if (r instanceof validate.ValidationError) {
    console.log('ERROR:', r);
  }
});

Install

npm install sirenlint -g

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free