Skip to main content

check_predicate_iri

Function check_predicate_iri 

Source
pub fn check_predicate_iri(predicate: &str) -> Result<(), DTGCredentialError>
Expand description

Checks that predicate is a well-formed predicate IRI: absolute, not a compact form, and in Unicode Normalization Form C.

A verifier MUST reject a credential whose predicate is not an absolute IRI, and no expansion is performed: a compact form is malformed, not unknown. This library applies that at parse, at issue and when checking against an accept-list.

§Telling an IRI from a CURIE

dtg:witnessed is syntactically an absolute IRI with the scheme dtg, so syntax alone cannot refuse it. The rule applied is structural: the IRI must be hierarchical with an authority (scheme://authority…), or use one of the two non-hierarchical schemes a predicate plausibly lives under, urn: and did:. A predicate MUST resolve to its definition, so this admits every predicate a registry or a community can publish, and refuses every prefix:term a JSON-LD context would have to expand.

§Normalization

Comparison is on the IRI as written, so two predicates that render identically but differ as byte strings are two predicates. An IRI that is not in NFC could never match its canonical spelling, and is refused rather than normalized.

§Errors

DTGCredentialError::InvalidPredicate, naming what was wrong.