Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jankaszel/validate-web-annotation
Validate JSON objects against the Web Annotation Data Model specification
https://github.com/jankaszel/validate-web-annotation
annotation validation web-annotation
Last synced: 17 days ago
JSON representation
Validate JSON objects against the Web Annotation Data Model specification
- Host: GitHub
- URL: https://github.com/jankaszel/validate-web-annotation
- Owner: jankaszel
- License: mit
- Created: 2020-07-14T17:03:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T06:02:37.000Z (over 1 year ago)
- Last Synced: 2024-10-17T01:00:34.578Z (22 days ago)
- Topics: annotation, validation, web-annotation
- Language: JavaScript
- Homepage:
- Size: 61.5 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validating Web Annotations
A JavaScript library for validating JSON objects against the [Web Annotation Data Model (WADM) specification](https://www.w3.org/TR/annotation-model/) via [JSON Schema](https://json-schema.org).
`npm install validate-web-annotation`
This library is still under active development and only partially covers the WADM specification. While most general-purpose properties of an annotation are being properly validated (e.g., `id`, `target`, `body`), more specific properties such as `purpose` and `state` are missing validation. I intend this library to perform efficiently and general-purpose rather than covering the whole WADM specification. I'll explicitly specify the validation coverage in future versions.
## API
This library exposes a simple function for validating annotations:
`validateAnnotation(annotation, opts = {})`
Options:
* `optionalId`: The annotation's ID (`annotation.id`) becomes optional. Suited for validating not-yet-persisted annotations.Returns a boolean value on whether the input is valid or not.
```js
// see ./example.js for a full example
const validateAnnotation = require("validate-web-annotation");
const annotation = {
"@context": "http://www.w3.org/ns/anno.jsonld",
id: "http://example.org/anno1",
type: "Annotation",
// ...
};
const valid = validateAnnotation(annotation);
```## Benchmarks
In order to collect benchmarks on the schema-based validation approach, run the benchmarking suite (which uses [benchmark.js](https://benchmarkjs.com)) via `npm run bench`.
## License
MIT