Skip to content

joshuef/rdf-check-mate

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

RDF schema validator / man generation POC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published