silk.json.schema_format.

String format assertions for JSON Schema, without network access.

SchemaFormat.check checks the standard format names and accepts unknown names. Schema evaluation must opt in to assertions: a format annotation alone does not reject an instance.

Import as SchemaFormat with import silk.json.schema_format { SchemaFormat }.

Public declarations: 1.

SchemaFormat#

silk
pub struct SchemaFormat

Checks the standard JSON Schema string formats. No check performs DNS or network access.

Implementation SchemaFormat#

silk
impl SchemaFormat

Associated function known#

silk
pub fn known(name: string) -> bool

Returns whether name is a standard format implemented by this module.

Associated function check#

silk
pub effect fn check(name: string, value: string) -> bool ! RegexError | OutOfMemoryError ? &mut Allocator

Returns whether value satisfies name; an unknown format name returns true.

Details#

Dates and times use RFC 3339, durations its Appendix A, mailboxes RFC 5321 and RFC 6531, URI references RFC 3986, IRIs RFC 3987, and URI templates RFC 6570. International hostnames use nontransitional UTS #46 mapping and IDNA2008 contextual and bidirectional checks. Regex syntax uses ECMAScript Unicode mode. The function does not resolve names or references.

Errors#

  • OutOfMemoryError if temporary Unicode or regular-expression storage cannot be allocated.

  • RegexError if a regular expression exceeds the parser's resource limits. Invalid syntax returns false; operational failures are not treated as invalid instances.

Category: Data formats.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page