validate-iri
Version:
Validates an IRI according to RFC 3987
29 lines (28 loc) • 962 B
TypeScript
/**
* Possible ways of validating an IRI
*/
export declare enum IriValidationStrategy {
/**
* Validates the IRI according to RFC 3987.
*/
Strict = "strict",
/**
* Validates that the IRI has a valid scheme and does not contain any character forbidden by the Turtle specification.
*/
Pragmatic = "pragmatic",
/**
* Does not validate the IRI at all.
*/
None = "none"
}
/**
* Validate a given IRI according to the given strategy.
*
* By default the IRI is fully validated according to RFC 3987.
* But it is possible to do a lighter a faster validation using the "pragmatic" strategy.
*
* @param {string} iri a string that may be an IRI.
* @param {IriValidationStrategy} strategy IRI validation strategy.
* @return {Error | undefined} An error if the IRI is invalid, or undefined if it is valid.
*/
export declare function validateIri(iri: string, strategy?: IriValidationStrategy): Error | undefined;