Skip to content

feat(iiif-validator): add IIIF Presentation Manifest validator#426

Merged
ddeboer merged 2 commits into
mainfrom
feat/iiif-validator
Jun 4, 2026
Merged

feat(iiif-validator): add IIIF Presentation Manifest validator#426
ddeboer merged 2 commits into
mainfrom
feat/iiif-validator

Conversation

@ddeboer
Copy link
Copy Markdown
Member

@ddeboer ddeboer commented Jun 4, 2026

What

Adds @lde/iiif-validator, a small, dependency-light package that validates whether a URL dereferences to a valid IIIF Presentation Manifest.

import { validateManifest } from '@lde/iiif-validator';

const verdict = await validateManifest('https://example.org/manifest.json');
// { valid: true, reason: 'valid-manifest' } | { valid: false, reason: 'http-error' | … }

Why

A reusable building block for Linked Data tooling that needs to tell a declared IIIF manifest apart from one that actually resolves and parses. The first consumer is the Dataset Knowledge Graph, which moves IIIF conformance from declared to validated by dereferencing a sample of manifest URIs per dataset. IIIF is an international standard with no NDE specifics, so the verifier belongs here, as a sibling to distribution-probe / distribution-downloader.

Behaviour

  • Dereference over HTTP with Accept: application/ld+json, application/json, following redirects, using the global fetch with an AbortSignal timeout (default 10 000 ms). Both are injectable (fetch, timeoutMs).
  • Lightweight, version-aware structural check. HTTP 2xx, body parses as JSON, @context references an IIIF Presentation context, and type/@type indicates a manifest — accepting v3 (Manifest) and v2 (sc:Manifest). @context may be a string, array, or object. The version segment is accepted version-agnostically.
  • Strict failure semantics, no retries. Timeout, network error, non-2xx, unparseable body, missing IIIF @context, or wrong type all yield valid: false with a coarse reason. No deep JSON Schema validation, no dependency on the hosted IIIF Presentation Validator service.
  • Never throws. Every outcome is a ManifestValidation verdict.

Tests

Unit-tested through the public interface with an injected fake fetch (no network): v3 / v2 manifests, @context as string / array / object, and each failure reason (http-error, timeout, network-error, invalid-json, not-a-manifest).

ddeboer added 2 commits June 4, 2026 10:45
New dependency-light package exposing validateManifest(url, { fetch, timeoutMs }).

Dereferences a URL with Accept: application/ld+json and an AbortSignal timeout.

Lightweight version-aware check: accepts v2 (sc:Manifest) and v3 (Manifest),

@context as string, array or object. Never throws; returns a coarse verdict. fetch is injectable.
@ddeboer ddeboer merged commit 5d8543c into main Jun 4, 2026
2 checks passed
@ddeboer ddeboer deleted the feat/iiif-validator branch June 4, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant