Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xml-tools/constraints

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xml-tools/constraints

XML constraints validations

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by19.11%
Maintainers
3
Weekly downloads
 
Created
Source

npm (scoped)

@xml-tools/constraints

Validations for XML constraints.

The following constraints are currently implemented:

  • Uniqueness of attribute keys inside the same element.
  • Element opening tag name must be identical to the element closing tag name.

Installation

With npm:

  • npm install @xml-tools/constraints

With Yarn

  • yarn add @xml-tools/constraints

Usage

Please see the TypeScript Definitions for full API details.

A simple usage example:

const { parse } = require("@xml-tools/parser");
const { buildAst } = require("@xml-tools/ast");
const { checkConstraints } = require("@xml-tools/constraints");

const xmlText = `
        <note>
          <to>Bill</to>
          <from>Tim</from>
        </note-typo>`;

const { cst, tokenVector } = parse(xmlText);
const document = buildAst(cst, tokenVector);
const validationIssues = checkConstraints(document);
console.log(validationIssues[0].msg); // --> 'opening tag: "note" must match closing tag: "note-typo"

Support

Please open issues on github.

Contributing

See CONTRIBUTING.md.

Keywords

FAQs

Package last updated on 03 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc