Skip to content
RDF schema validator / man generation POC
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
lib
src logger update Jan 23, 2019
.babelrc
.editorconfig INittt Oct 17, 2018
.eslintignore INittt Oct 17, 2018
.eslintrc INittt Oct 17, 2018
.gitignore add lib for now Jan 22, 2019
.travis.yml INittt Oct 17, 2018
CHANGELOG.md INittt Oct 17, 2018
README.md
appveyor.yml INittt Oct 17, 2018
jest.config.js
package.json Feat(Init): Initial commit for validation POC. w/ basic tests. Nov 7, 2018
yarn.lock

README.md

RDF Check Mate

Validation and documentation generation for JSON-LD schemas (in the schema.org fashion).

Currently very naive proof of concept.

Setup:

Install using yarn (needed for postinstall script/retrieval) yarn

Use

Valid:

// Checking against Book schema from schema.org
import { Book } from 'schema-doter';

const sampleObject = {
    'numberOfPages' : 4,
    'title'         : 'Dave',
    'author'        : 'me',
    'published'     : 'now',
    'publisher'     : 'yes '
};

valid = validate( Book, {...sampleObject, numberOfPages: 4.2222} );

// This warns in console:
//
// There is some incompatability between your provided object and the schema...
//  title , published do not exist on this schema

// But:
console.log( valid ) // true

Invalid:

const badObject = {
    'numberOfPages' : 4.1,
    'title'         : 'Dave',
    'author'        : 'me',
    'published'     : 'now',
    'publisher'     : 'yes '
};

valid = validate( Book, {...badObject, numberOfPages: 4.2222} );
console.log( valid ) // false

// also throws:
// Candidate data type error: 4.1 is number should be: Integer

TODO

  • Publish as npm package?
    • Setup main script / build / etc
  • Add tests
  • use RDFlib for extracting props etc.
  • setup CI
  • Add validity checks for more data types and classes etc
You can’t perform that action at this time.