Grammar and comparison
Every IID has the form int:<scheme>:<value>. This page lists the syntax, the parsing rule that implementations most often get wrong and the three checks that make an identifier valid. The grammar is frozen permanently: it will never change within this specification. IID spec §1.5.1
Syntax
iid = "int" ":" scheme ":" value
scheme = 1*32 scheme-char
scheme-char = %x61-7A / DIGIT / "-" ; a-z, 0-9, hyphen
value = 1*220 value-char
value-char = %x21-7E ; visible ASCII, no space
| Rule | Requirement |
|---|---|
| Prefix | Exactly int:, case-sensitive. INT: and Int: are not IIDs. |
| Scheme | 1–32 lowercase ASCII letters, digits or hyphens, and registered in the scheme catalog. |
| Value | 1–220 visible ASCII characters (0x21–0x7E). No spaces. |
| Total length | At most 256 bytes. This is the binding limit. The per-part maxima cannot both be reached in one IID. |
| Non-ASCII text | Never appears raw. It enters only through a gen1 hash or a scheme-specific encoding, such as percent-encoding in a URL. |
Parse on the first two colons
A parser splits on the first two colons only. Everything after the second colon is the value, including any further colons. Splitting on every colon is the most common implementation error. A generic parser also does not interpret structure inside the value. Only the scheme's own rules do that. IID spec §2.3
| IID | Scheme | Value |
|---|---|---|
int:isbn:9780684832722 | isbn | 9780684832722 |
int:caip10:eip155:1:0xd8da6bf26964af9d7eed9e03e53415d37aa96045 | caip10 | eip155:1:0xd8da6bf26964af9d7eed9e03e53415d37aa96045 |
int:gen1:movie:r4:fb681afe7d438cad73ae90a70f1cc55a | gen1 | movie:r4:fb681afe7d438cad73ae90a70f1cc55a |
int:hash:sha256:… | hash | sha256:… |
Validate in three steps
A string is a valid IID only when all three checks pass, in this order. IID spec §2.7
- Shape. Match the non-normative reference expression
^int:([a-z0-9-]{1,32}):([\x21-\x7E]{1,220})$and check the 256-byte limit. - Registered scheme. Reject the IID if its scheme is not in the registry, even when the string is otherwise well-formed. The registry is closed. Validators never pass unknown schemes through. IID spec §9.1
- Canonical value. Run the scheme's canonicalization and reject the IID if the value changes. A canonical value satisfies
canonicalize(value) = value.
For example, int:isbn:0-684-83272-0 is well-formed but invalid, because the canonical ISBN form is the 13-digit 9780684832722. Canonicalize the raw ISBN first, then build int:isbn:9780684832722. IID spec §2.5
Compare byte for byte
Two IIDs are equal if and only if their byte sequences are identical. Comparison ignores no case, Unicode form or whitespace differences. Canonicalize before comparing, never during the comparison. Lowercasing a whole IID can change its meaning, because some schemes preserve case in their values. IID spec §2.4
This makes a canonical IID a safe key for a unique database index or a cache. Two importers that canonicalize the same source value produce identical text. IID spec §8.2
Relationship to URNs
The grammar follows URN discipline without claiming RFC 8141 conformance. RFC 8141 treats some parts of a URN as case-insensitive, which conflicts with byte-exact comparison. Where a URN is required, map int:<scheme>:<value> to urn:int:<scheme>:<value> and back without changing the value. IID spec §2.6
Related
- Scheme catalog lists every registered scheme with an input and its canonical IID.
- Conformance and test vectors explains how to check a validator against the published vectors.
- Schemes and canonical form applies these rules to a recording identifier.
Applies to V2 · @0xintuition/iid 0.1.1