Skip to content

Type Alias: DiscoveredConstraintDto

@kortexya/reasoninglayer


@kortexya/reasoninglayer / DiscoveredConstraintDto

DiscoveredConstraintDto = { type: "not_null"; } | { type: "unique"; } | { type: "primary_key"; } | { expression: string; type: "check"; } | { max?: number | null; min?: number | null; type: "range"; } | { regex: string; type: "pattern"; } | { type: "one_of"; values: string[]; } | { column: string; table: string; type: "foreign_key"; } | { length: number; type: "max_length"; } | { length: number; type: "min_length"; } | { type: "default"; value: string; }

Defined in: src/types/sources.ts:81

One constraint the source declares on a discovered field, tagged by type.

{ type: "not_null"; }


{ type: "unique"; }


{ type: "primary_key"; }


{ expression: string; type: "check"; }

A check constraint; expression is verbatim from the source.


{ max?: number | null; min?: number | null; type: "range"; }

Inclusive bounds; null or absent means unbounded on that side.


{ regex: string; type: "pattern"; }

regex is verbatim from the source.


{ type: "one_of"; values: string[]; }


{ column: string; table: string; type: "foreign_key"; }


{ length: number; type: "max_length"; }


{ length: number; type: "min_length"; }


{ type: "default"; value: string; }

A default expression or literal, verbatim from the source.

Wire format: an internally tagged object, snake_case tags ({"type": "max_length", "length": 50}, {"type": "range", "min": 0, "max": null}). The engine sent a Rust debug string here before ("MaxLength { length: 50 }"); it now sends this typed value, so read the allowed values of an enum column or the length cap of a string as data. Bounds, expressions and patterns are carried verbatim from the source.

From a relational source a constraint is declared by the schema. From a sampled source (CSV) unique states what the sampled rows showed — a hint, not a guarantee.

const maxLength = feature.constraints?.find((c) => c.type === 'max_length');
if (maxLength?.type === 'max_length') console.log(maxLength.length); // 50