- TypeScript 98.2%
- JavaScript 1.8%
chore(deps): update dependency @redocly/cli to v2.14.2 See merge request logius/nldoc/spec/validation!356 |
||
|---|---|---|
| .vscode | ||
| src | ||
| test | ||
| .editorconfig | ||
| .eslintrc | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .npmrc | ||
| .nvmrc | ||
| .prettierignore | ||
| .prettierrc | ||
| .releaserc | ||
| CHANGELOG.md | ||
| CODEOWNERS | ||
| eslint.config.mjs | ||
| example-generator.yaml | ||
| index.ts | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| prettier.config.mjs | ||
| README.md | ||
| renovate.json | ||
| tsconfig.dist.json | ||
| tsconfig.json | ||
NLdoc Document Validation Specification
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
-
Clone the repository:
git clone https://gitlab.com/logius/nldoc/spec/validation.git cd validation-specification -
Install dependencies:
npm install -
Build the project:
npm run build
Available Scripts
npm run test- Run the test suite with Vitestnpm run build- Build the OpenAPI specification, examples, and TypeScript filesnpm run lint- Lint the codebase using ESLintnpm run format- Format code using Prettiernpm run format:check- Check code formattingnpm run fix- Auto-fix linting and formatting issuesnpm run lint:openapi- Generate an HTML report for the OpenAPI specification
Building Components
The build process consists of several steps:
- OpenAPI Generation:
npm run build:openapi- Generates the OpenAPI JSON specification - Example Extraction:
npm run build:examples- Extracts valid and invalid test examples - TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
- 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:
- Locally: After building, open
public/index.htmlin your browser - Online: View the latest release documentation
Related Specifications
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:
- All tests pass (
npm test) - Code is properly formatted (
npm run format:check) - Linting rules are followed (
npm run lint) - 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
- Built on OpenAPI 3.1.0 specification
- Integrates with NLdoc Document Specification
- Uses Redocly for API documentation generation