Type Alias: DiscoveredConstraintDto
@kortexya/reasoninglayer / DiscoveredConstraintDto
Type Alias: DiscoveredConstraintDto
Section titled “Type Alias: 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.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ type: "not_null"; }
Type Literal
Section titled “Type Literal”{ type: "unique"; }
Type Literal
Section titled “Type Literal”{ type: "primary_key"; }
Type Literal
Section titled “Type Literal”{ expression: string; type: "check"; }
A check constraint; expression is verbatim from the source.
Type Literal
Section titled “Type Literal”{ max?: number | null; min?: number | null; type: "range"; }
Inclusive bounds; null or absent means unbounded on that side.
Type Literal
Section titled “Type Literal”{ regex: string; type: "pattern"; }
regex is verbatim from the source.
Type Literal
Section titled “Type Literal”{ type: "one_of"; values: string[]; }
Type Literal
Section titled “Type Literal”{ column: string; table: string; type: "foreign_key"; }
Type Literal
Section titled “Type Literal”{ length: number; type: "max_length"; }
Type Literal
Section titled “Type Literal”{ length: number; type: "min_length"; }
Type Literal
Section titled “Type Literal”{ type: "default"; value: string; }
A default expression or literal, verbatim from the source.
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”const maxLength = feature.constraints?.find((c) => c.type === 'max_length');if (maxLength?.type === 'max_length') console.log(maxLength.length); // 50