The value to validate as an IRI
The identifier variant to validate against (default: "relative")
true if the value is a well-formed string conforming to IRI syntax rules for the specified variant;
false otherwise
This function serves as a type guard, narrowing the type from string to IRI
when used in conditional checks.
Checks if a value is a valid IRI.
Validates IRIs according to RFC 3987 with variant-specific rules:
"hierarchical": Absolute with root-relative path (scheme:/...) — can be used as resolution base"absolute": Hierarchical or opaque (scheme:...)"internal": Root-relative (/...) or absolute"relative": Any well-formed referencePaths are normalized per RFC 3986 § 5.2.4, which clips
..segments climbing above the root rather than rejecting them, so/a/../../xis accepted wherever the/xit denotes is. References opening with//name an authority (RFC 3986 § 4.2) and are rejected whatever the variant, as no variant admits an authority supplied by a reference.Excluded characters (per RFC 3987 § 2.2): Control characters (U+0000-U+001F, U+007F-U+009F), whitespace, and
< > " { } | \ ^ ``(backtick)Ill-formed text: Strings carrying an isolated UTF-16 surrogate are rejected in every variant: the
ucscharproduction of RFC 3987 § 2.2 skips the surrogate block U+D800-U+DFFF, so no conforming IRI holds one, and encoding such a string to UTF-8, as percent-encoding requires, would substituteU+FFFDREPLACEMENT CHARACTER for the surrogate, yielding a different identifier