Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openknowledge-archive/datapackage-validate-js
[DEPRECATED] Replacement: https://github.com/frictionlessdata/datapackage-js
https://github.com/openknowledge-archive/datapackage-validate-js
Last synced: 13 days ago
JSON representation
[DEPRECATED] Replacement: https://github.com/frictionlessdata/datapackage-js
- Host: GitHub
- URL: https://github.com/openknowledge-archive/datapackage-validate-js
- Owner: openknowledge-archive
- Created: 2014-03-15T13:32:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-29T14:43:42.000Z (almost 9 years ago)
- Last Synced: 2024-05-21T09:13:14.843Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 5
- Watchers: 14
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-data-ui - data-package-validate
README
datapackage-validate
====================Validate [Data Package][] datapackage.json files.
[Data Package]: http://data.okfn.org/doc/data-package
# Installation
[![NPM](https://nodei.co/npm/datapackage-validate.png)](https://nodei.co/npm/datapackage-validate/)
```
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](https://github.com/dataprotocols/registry), which is used to retrieve the matching schemaNote the method is asynchronous and returns a Promise (implemented with [bluebird](https://www.npmjs.com/package/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](https://github.com/dataprotocols/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