Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

xsd-schema-validator

nikku60.6kMIT0.11.0TypeScript support: included

A (XSD) schema validator for nodejs

xsd, xml, schema, validator, validation

readme

xsd-schema-validator

CI

A (XSD) schema validator for NodeJS that uses Java to perform the actual validation. :arrow_right: Why?

Prerequisites

Under the hood, this utility uses Java to do the actual validation.

It assumes that javac and java are on the path. If a JAVA_HOME environment variable exists it uses that to locate an installed JDK.

On some platforms, i.e. Mac OSX you need to define JAVA_HOME manually.

Installation

Install the package via npm:

npm install --save xsd-schema-validator

Usage

Use in your application:

var validator = require('xsd-schema-validator');

var xmlStr = '<foo:bar />';

try {
  const result = await validator.validateXML(xmlStr, 'resources/foo.xsd');

  result.valid; // true
} catch (err) {
  console.error('validation error', err);
}

You may validate readable streams:

var xmlStream = fs.createReadableStream('some.xml');

const result = await validator.validateXML(xmlStream);

You may validate files, too:

const result = validator.validateXML({ file: 'some.xml' }, ...);

Why

Because Java can do schema validation and NodeJS cannot.

License

MIT

changelog

Changelog

All notable changes to node-xsd-schema-validator are documented here. We use semantic versioning for releases.

Unreleased

_Note: Yet to be released changes appear here._

0.11.0

  • FEAT: add insecure option to be able to parse huge schemata (#44)

0.10.0

  • CHORE: simplify path resolution
  • CHORE: log setup error with human readable message
  • CHORE: require Node >= 18

0.9.0

  • FEAT: add type definitions (#36, #37)

0.8.1

  • FIX: ship support folder

0.8.0

  • FEAT: change to Promise-based API, drop callbacks
  • CHORE: require node >= 16
  • DEPS: update to which@4

0.7.0

  • FEAT: setup validation helper post install
  • FEAT: add validator #setup hook
  • FEAT: allow debug mode to be toggled via environment variable
  • FEAT: gracefully handle missing java/javac

...

Check git log for earlier history.