This package has been deprecated

Author message:

Please use https://github.com/frictionlessdata/datapackage-js

datapackage-validate

0.2.5 • Public • Published

datapackage-validate

Validate Data Package datapackage.json files.

Installation

NPM

npm install datapackage-validate

Usage

Following assume you've imported the module as follows:

var validator = require('datapackage-validate');

validate

Validate the provided object or string as a Data Package.

validator.validate(raw, schema)
  • raw: datapackage.json string or object to validate (note method will take care of parsing the string and checking it is valid JSON if it is not parsed already)
  • schema: A schema to validate raw against, or, a string that is the unique identifier for a schema in the Data Package Registry, which is used to retrieve the matching schema

Note the method is asynchronous and returns a Promise (implemented with bluebird). The Promise resolves with following structure:

{
  valid: true | false,
  errors: [
    {
      // every error has a message
      message: 'Invalid JSON: ...'
      // JSON errors come from json-lint and will also have
      line: 
    },
    {
      message: 'Array is too short (0), minimum 1',
      // schema errors come from schema validator and include additiona
      // path in input JSON
      dataPath: '/resources',
      // path in schema
      schemaPath: '/properties/resources/minItems',
    },
    ...
  ]
  warnings: [
    {
      message: 'No title field'
    },
    ...
  ]
};

Changelog

  • v0.3.0:
    • Adds support for any Profile in the Data Package Registry
    • API is now async using bluebird Promises
    • Removes hardcoded schemas
    • Removes validateUrl
  • v0.2.0: #1, #2, #4 (jsonlint, much better schema validation using official schemas)
  • v0.1.0: first working release

Readme

Keywords

none

Package Sidebar

Install

npm i datapackage-validate

Weekly Downloads

2

Version

0.2.5

License

MIT

Last publish

Collaborators

  • roll