jsonschema: model URI and IRI formats
The JSON Schema specification allows for modeling resource identifiers, such as URIs and IRIs, using the format keyword to specify that a string is of a specific type (e.g., uri, iri, uuid).
For example, in JSON Schema, this can be defined as follows:
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
To the best of my understanding, CUE does not directly support the URI or IRI string formats as part of its standard types. What is the recommended approach or best practice in CUE for modeling such formats?
cc @rogpeppe
Currently AFAIK best approach is to use a regular expression (the first one I came across is here) but that's not ideal, clearly, given the size of it.
We should add a validator for this format, perhaps in a new net/url package. Given that we will want to support JSONSchema formats directly when importing JSON Schema into CUE, we will probably have direct support for most or all of those formats in the near(ish) future. Watch this space!
I believe this was done in https://review.gerrithub.io/c/cue-lang/cue/+/1202106, as part of https://github.com/cue-lang/cue/issues/3479, back in October 2024.