# rdf-validation

> Validate RDF/JS objects

Latest version **0.1.1** (published 2024-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install rdf-validation
pnpm add rdf-validation
yarn add rdf-validation
bun add rdf-validation
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2024-06-22 |
| First published | 2024-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 77.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Thomas Bergwinkl |
| Keywords | datatype, literal, model, rdf, rdfjs, validate, validation, xsd |

## Links

- npm: https://www.npmjs.com/package/rdf-validation
- Repository: https://github.com/rdf-ext/rdf-validation
- Issues: https://github.com/rdf-ext/rdf-validation/issues
- npm.io page: https://npm.io/package/rdf-validation

## Dependencies (4)

- [@rdfjs/term-map](https://npm.io/package/@rdfjs/term-map.md) ^2.0.0
- [@rdfjs/namespace](https://npm.io/package/@rdfjs/namespace.md) ^2.0.0
- [@rdfjs/data-model](https://npm.io/package/@rdfjs/data-model.md) ^2.0.1
- [@rdfjs/to-ntriples](https://npm.io/package/@rdfjs/to-ntriples.md) ^3.0.1

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2024-06-22
- 0.1.0 — 2024-02-04

## README

# rdf-validation

[![build status](https://img.shields.io/github/actions/workflow/status/rdf-ext/rdf-validation/test.yaml?branch=master)](https://github.com/rdf-ext/rdf-validation/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/rdf-validation.svg)](https://www.npmjs.com/package/rdf-validation)

`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

```bash
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:


```js
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.

---
_Source: https://npm.io/package/rdf-validation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
