Code Monkey home page Code Monkey logo

rdf-validation's Introduction

rdf-validation

build status npm version

rdf-validation is a modular library to validate RDF data provided as RDF/JS objects. Different modules can be combined to tailor a validation according to personal needs.

Install

npm install --save rdf-validation

Usage

The package exports multiple validations. All validations are classes, and it requires creating instances for them. A validation object has a .validate() and a .validateSimple() method. .validate() returns a Report with results for different checks and includes a message. .validateSimple() is an optimized method that returns only true if the given object is valid and false in case it is not.

Example

See the following example on how to check if quads match the RDF Model and literal values are valid according to the XSD specification:

import rdf from 'rdf-ext'
import { RdfModelValidation, XsdValidation } from '../index.js'

const rdfModelValidation = new RdfModelValidation({ factory: rdf })
const xsdValidation = new XsdValidation({ factory: rdf })

const quad = rdf.quad(
  rdf.literal('resource'),
  rdf.namedNode('https://example.org/date'),
  rdf.literal('1.1.2001', rdf.namedNode('http://www.w3.org/2001/XMLSchema#date'))
)

const rdfReport = rdfModelValidation.validate(quad)
console.log(`conforms: ${rdfReport.conforms}`)
console.log(`message: ${rdfReport.results[0].message[0]}`)
console.log(`validateSimple: ${rdfModelValidation.validateSimple(quad)}`)

const xsdReport = xsdValidation.validate(quad.object)
console.log(`conforms: ${xsdReport.conforms}`)
console.log(`message: ${xsdReport.results[0].message[0]}`)
console.log(`validateSimple: ${xsdValidation.validateSimple(quad.object)}`)

See the examples folder for more examples.

rdf-validation's People

Contributors

bergos avatar dependabot[bot] avatar

Stargazers

Cristian Vasquez avatar Pieter J.C. van Everdingen 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.