# validate-iri

> Validates an IRI according to RFC 3987

Latest version **1.0.1** (published 2022-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install validate-iri
pnpm add validate-iri
yarn add validate-iri
bun add validate-iri
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-11-09 |
| First published | 2022-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Ruben Taelman |
| Maintainers | rubensworks |
| Keywords | IRI, validate, validator, RFC3987, URI, URL |

## Links

- npm: https://www.npmjs.com/package/validate-iri
- Repository: https://github.com/comunica/validate-iri.js
- Homepage: https://github.com/comunica/validate-iri.js#readme
- Issues: https://github.com/comunica/validate-iri.js/issues
- npm.io page: https://npm.io/package/validate-iri

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-11-09
- 1.0.0 — 2022-08-16

## README

# Validate IRI

[![Build status](https://github.com/comunica/validate-iri.js/workflows/CI/badge.svg)](https://github.com/comunica/validate-iri.js/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/comunica/validate-iri.js/badge.svg?branch=master)](https://coveralls.io/github/comunica/validate-iri.js?branch=master)
[![npm version](https://badge.fury.io/js/validate-iri.svg)](https://www.npmjs.com/package/validate-iri)

This tool validates an IRI, either using strict RFC 3987 grammar, or using a faster but less strict pragmatic validation mode.
It works in both JavaScript and TypeScript.

## Installation

```bash
$ npm install validate-iri
```
or
```bash
$ yarn add validate-iri
```

This package also works out-of-the-box in browsers via tools such as [webpack](https://webpack.js.org/) and [browserify](http://browserify.org/).

## Usage

Multiple validation modes are provided:
- `IriValidationStrategy.Strict`: carefully validates the IRI using RFC 3987 grammar. This is the default value.
- `IriValidationStrategy.Pragmatic`: quickly validates that the IRI has a valid scheme and does not contain any character forbidden by the N-Triples, Turtle and N3 grammars.
- `IriValidationStrategy.None`: does not validate the IRI at all.

Example:
```
import { validateIri, IriValidationStrategy } from 'validate-iri`
const yourIri = 'https://example.com/john-doe'
validateIri(yourIri, IriValidationStrategy.Pragmatic) // Will throw an error if the IRI is invalid.
```

## Performance

When using strict validation mode, a significant performance overhead should be taken into account.
In isolation, strict validation is an order of magnitude slower than pragmatic validation.

When used in a parser such as [rdfxml-streaming-parser.js](https://github.com/rdfjs/rdfxml-streaming-parser.js/), the performance impact on parsing is the following (GeoSpecies Knowledge Base with 1.8M triples):

- Strict validation: 12.053s
- Pragmatic validation: 9.116s
- No validation: 8.338s

## License

This code is released under the [MIT license](http://opensource.org/licenses/MIT).

---
_Source: https://npm.io/package/validate-iri · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
