contract

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package contract enforces the funcd contract type profile (ADR-0058): the bounded, language-agnostic subset of JSON Schema 2020-12 that a function's I/O contract may use — "the def" (the discipline JTD and WIT apply). A contract is GENERATED from the author's code type (typia / pydantic) and then run through Check before it is shipped or embedded, so a contract can never advertise a shape a peer runtime (or the registry) can't honor.

Supported: scalars (string + formats/pattern/length, integer, number, boolean), string enums, CLOSED objects (additionalProperties:false), arrays, string-keyed maps (additionalProperties:<type>, no properties), DISCRIMINATED unions (oneOf + discriminator), optional/nullable, and the explicit `Json` form (the empty schema {} — arbitrary JSON).

Forbidden (Check returns a fault.Invalid naming the construct): OPEN records (additionalProperties true/absent on a record), NON-DISCRIMINATED oneOf/anyOf/allOf, not, if/then/else, external/recursive $ref, and recursive types (which require $ref).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(schemaJSON []byte) error

Check reports whether a JSON Schema (a generated function I/O contract) lies within the funcd profile. It returns nil when every construct is supported, or a fault.Invalid whose message names the first unsupported construct and its JSON-pointer-ish path. A nil/empty input is treated as the `Json` (any) form — valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL