contract_check

A table against a contract: expectation results with observed, expected, severity and samples.

QueryDeterministic

Flags

Flag Value
Kind query: reads values
Rows one result, not a table
Deterministic yes
Order matters no
Decomposable no
Makes no value

Parameters

Parameter Type Required Notes
table reference yes A value's reference.
contract object yes A hint.contract/1 document.
references map of reference no Tables the contract's reference rules name.
response_format "concise" | "detailed" no The byte budget: 64 KiB concise, 512 KiB detailed.

Example

Over the example tables customers; ${input:name} is an input's reference and ${verb} the value an earlier call made.

JSON
contract_check {
  "table": "${input:customers}",
  "contract": {
    "version": "hint.contract/1",
    "name": "customers",
    "columns": [
      {
        "name": "cid",
        "logicalType": "integer",
        "primaryKey": true
      }
    ]
  }
}

Result

0 of 3 rules failed

JSON
{
  "passed": true,
  "records": "…"
}

Diagnostics

A refusal comes back as ok: false with coded diagnostics; every code, with its fix, is on the diagnostics page. A parameter that does not match the schema above is ARG_INVALID, with the parameter's path.