• TypeScript 98.2%
  • JavaScript 1.8%
Find a file
DigiToegankelijk NLdoc 471fb4ba68 Merge branch 'renovate/redocly-cli-2.x-lockfile' into 'main'
chore(deps): update dependency @redocly/cli to v2.14.2

See merge request logius/nldoc/spec/validation!356
2025-12-30 20:20:01 +00:00
.vscode chore: update eslint and prettier configs 2024-07-29 19:14:14 +02:00
src fix: update references (GitLab migration) 2025-04-03 21:15:33 +02:00
test chore: handle empty example set 2025-07-29 12:01:50 +02:00
.editorconfig chore: set .editorconfig 2025-04-22 01:06:09 +00:00
.eslintrc chore: update eslint and prettier configs 2024-07-29 19:14:14 +02:00
.gitignore chore: update eslint and prettier configs 2024-07-29 19:14:14 +02:00
.gitlab-ci.yml fix: update references (GitLab migration) 2025-04-03 21:15:33 +02:00
.npmrc fix: linting stuff 2025-04-03 21:51:21 +02:00
.nvmrc chore(deps): update node.js to v24 2025-11-04 01:11:38 +00:00
.prettierignore chore: update eslint and prettier configs 2024-07-29 19:14:14 +02:00
.prettierrc chore: update eslint and prettier configs 2024-07-29 19:14:14 +02:00
.releaserc fix: .releaserc for releasing 2024-09-01 17:12:41 +02:00
CHANGELOG.md chore(release): 3.0.135 2025-05-12 14:21:14 +00:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:25:43 +00:00
eslint.config.mjs fix: update references (GitLab migration) 2025-04-03 21:15:33 +02:00
example-generator.yaml feat: add example tests and artifacts 2024-08-20 14:24:43 +02:00
index.ts fix: import assertion -> with 2025-04-03 21:44:23 +02:00
LICENSE chore: add license 2025-04-15 00:18:25 +02:00
package-lock.json chore(deps): update dependency @redocly/cli to v2.14.2 2025-12-30 20:09:52 +00:00
package.json chore(deps): update node.js to v24 2025-11-04 01:11:38 +00:00
prettier.config.mjs fix: update references (GitLab migration) 2025-04-03 21:15:33 +02:00
README.md docs: update readme 2025-08-18 11:45:49 +02:00
renovate.json chore: npm install twice 2025-11-05 14:07:23 +00:00
tsconfig.dist.json fix: NLD-22 building output to npm package 2024-09-01 16:36:04 +02:00
tsconfig.json fix: NLD-22 building output to npm package 2024-09-01 16:36:04 +02:00

NLdoc Document Validation Specification

pipeline status coverage report Latest Release NPM Version

An OpenAPI 3.1.0 compatible specification for representing validation messages and notifications. This TypeScript library provides a standardized schema framework for validation findings that can be used to annotate resources in the NLdoc Document Specification.

Overview

This specification defines a standardized way to represent validation messages and notifications for digital documents, including:

  • Validation findings with severity levels
  • Error reporting structures
  • Rule-based validation annotations
  • Ruleset and rule versioning

The specification provides a consistent, type-safe way to describe validation results, enabling better document quality assurance, error reporting, and integration with document validation systems.

Getting Started

Prerequisites

  • Node.js >= 22.0.0 < 23.0.0
  • npm >= 10.0.0 < 12.0.0

Installation

Install the package via npm:

npm install @nldoc/document-validation-specification

Or using yarn:

yarn add @nldoc/document-validation-specification

Basic Usage

import {
  specification,
  validExamples,
  invalidExamples
} from '@nldoc/document-validation-specification';

// Access the OpenAPI specification
console.log(specification);

// Use valid examples for testing
console.log(validExamples);

// Use invalid examples for validation testing
console.log(invalidExamples);

Accessing the OpenAPI Specification

After building the project, the complete OpenAPI 3.1.0 specification is available at:

# Build the project first
npm run build

# The OpenAPI specification is now available at:
# - public/openapi.json (JSON format)
# - public/index.html (Interactive HTML documentation)

Development

Local Setup

  1. Clone the repository:

    git clone https://gitlab.com/logius/nldoc/spec/validation.git
    cd validation-specification
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

Available Scripts

  • npm run test - Run the test suite with Vitest
  • npm run build - Build the OpenAPI specification, examples, and TypeScript files
  • npm run lint - Lint the codebase using ESLint
  • npm run format - Format code using Prettier
  • npm run format:check - Check code formatting
  • npm run fix - Auto-fix linting and formatting issues
  • npm run lint:openapi - Generate an HTML report for the OpenAPI specification

Building Components

The build process consists of several steps:

  1. OpenAPI Generation: npm run build:openapi - Generates the OpenAPI JSON specification
  2. Example Extraction: npm run build:examples - Extracts valid and invalid test examples
  3. TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
  4. Documentation: npm run build:redocly - Generates HTML documentation using Redocly

Validation Types

The specification supports various validation elements:

Core Resources

  • ValidationFinding: A validation finding with severity, rule information, and resource reference
  • Error: Error reporting structure for validation failures

Properties

  • Id: Unique identifier for validated resources
  • Severity: Validation severity levels (error, warning, info)
  • Type: Resource type identifiers

Validation Attributes

  • resourceId: Reference to the validated resource
  • severity: The severity level of the finding
  • ruleset: URI of the validation ruleset
  • rulesetVersion: Version of the ruleset
  • rule: Specific rule identifier that triggered the finding

API Documentation

The generated OpenAPI specification can be viewed:

  1. Locally: After building, open public/index.html in your browser
  2. Online: View the latest release documentation

This specification is designed to work with the NLdoc Document Specification, providing validation annotations for document resources.

Testing

Run the test suite:

npm test

Contributing

We welcome contributions! Please ensure:

  1. All tests pass (npm test)
  2. Code is properly formatted (npm run format:check)
  3. Linting rules are followed (npm run lint)
  4. OpenAPI specification is valid (npm run lint:openapi)

License

This project is licensed under the European Union Public License 1.2 - see LICENSE for details.

Acknowledgements