Socket
Socket
Sign inDemoInstall

datapackage-validate

Package Overview
Dependencies
84
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    datapackage-validate

Validate Data Packages


Version published
Maintainers
4
Install size
7.71 MB
Created

Readme

Source

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

FAQs

Last updated on 29 Dec 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc