# barnard59-validate-shacl

> A barnard59 step that validates RDF using the Shapes Constraint Language (SHACL).

Latest version **0.3.8** (published 2023-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install barnard59-validate-shacl
pnpm add barnard59-validate-shacl
yarn add barnard59-validate-shacl
bun add barnard59-validate-shacl
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.8 |
| Published | 2023-02-06 |
| First published | 2021-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/barnard59-validate-shacl) |
| Module format | ESM + CommonJS |
| Node | >= 14.0.0 |
| Dependencies | 5 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zazuko GmbH |
| Maintainers | bergos, cristianvasquez |

## Links

- npm: https://www.npmjs.com/package/barnard59-validate-shacl
- Repository: https://github.com/zazuko/barnard59-validate-shacl
- Issues: https://github.com/zazuko/barnard59-validate-shacl/issues
- npm.io page: https://npm.io/package/barnard59-validate-shacl

## Dependencies (5)

- [rdf-ext](https://npm.io/package/rdf-ext.md) ^2.0.1
- [is-stream](https://npm.io/package/is-stream.md) ^3.0.0
- [@rdfjs/fetch](https://npm.io/package/@rdfjs/fetch.md) ^3.0.0
- [rdf-dataset-ext](https://npm.io/package/rdf-dataset-ext.md) ^1.0.0
- [rdf-validate-shacl](https://npm.io/package/rdf-validate-shacl.md) ^0.4.0

## Recent versions

- 0.3.8 (latest) — 2023-02-06
- 0.3.7 — 2022-01-12
- 0.3.6 — 2022-01-11
- 0.3.5 — 2021-12-06

## README

#  barnard59-validate-shacl

A barnard59 step that validates RDF using the [Shapes Constraint Language](https://www.w3.org/TR/shacl) (SHACL).

## Install

```
npm install barnard59-validate-shacl --save
```

## Exported steps

### `validate`

Validates a chunk of RDF against a set of conditions specified in a SHACL graph.

The argument is a RDF stream containing the SHACL shapes.

```turtle
prefix : <https://pipeline.described.at/>
prefix code: <https://code.described.at/>

<#shaclValidate> a :Step ;
  code:implementedBy
    [
      a code:EcmaScriptModule ;
      code:link <node:barnard59-validate-shacl/validate.js#shacl>
    ] ;
  code:arguments ( <#CubeShapes> ) ;
.
```

> Note that this operation does not take care of partitioning the data, using this operation requires to prepare the data accordingly.

To pass additional options, initialize the step with named arguments instead. All except `shape` are optional.

```turtle
prefix : <https://pipeline.described.at/>
prefix code: <https://code.described.at/>

<#shaclValidate> a :Step ;
  code:implementedBy
    [
      a code:EcmaScriptModule ;
      code:link <node:barnard59-validate-shacl/validate.js#shacl>
    ] ;
  code:arguments
    [ code:name "shape" ; code:value <#CubeShapes> ] ,
    # validation will stop when the given number is reached (default 1)
    # set to 0 to report all errors    
    [ code:name "maxErrors" ; code:value 100 ] ,
    # callback function which allows pipeline authors to perform
    # additional actions and/or decide to continue the pipeline 
    # when SHACL violations are encountered (see below)
    [ 
      code:name "onViolation" ; 
      code:value [ a code:EcmaScriptModule ; code:link <file:...> ] ;
    ] ;
.
```

#### `onViolation`

The function below could be used to continue the pipeline when SHACL violations are found but none of them are `sh:Violation`.

```js
import { sh } from '@tpluscode/rdf-ns-builders'

/**
* @param context {Object} Pipeline context
* @param data {DatasetCore} Data graph which failed validation
* @param report {ValidationReport}
*/
export function continueOnWarnings({ context, data, report }) {
    const hasViolations = report.results.some(({ severity }) => severity.equals(sh.Violation))

    return !hasViolations
}
```

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