GithubHelp home page GithubHelp logo

opleban / datapackage-validate-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openknowledge-archive/datapackage-validate-js

0.0 1.0 0.0 21 KB

Validate Data Package DataPackage.json files (Node and Javascript)

Home Page: http://data.okfn.org/

JavaScript 100.00%

datapackage-validate-js's Introduction

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

datapackage-validate-js's People

Contributors

borysyuk avatar pwalsh avatar rufuspollock avatar zerberio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.