Skip to Content
We are live but in Staging 🎉

Constraints

Constraints attach validation rules to a field type. They appear on the same line, directly after the type, and multiple clauses can stack. The supported clauses are grouped by the type they apply to.

Numeric constraints (on number / integer)

ClauseMeaning
range(min, max)value must be within [min, max]
min(n)value must be >= n
max(n)value must be <= n
input box_threshold : number range(0.0, 1.0) = 0.35 top_k : number range(1, 1000) = 10 padding : number min(0) = 0 chunk_size : integer min(100) max(50000) = 2000

String constraints (on text)

ClauseMeaning
length(min, max)character count must be within [min, max]
pattern("regex")must match the ECMA-262 regular expression
input collection_name : text length(1, 256) artifact_id : text length(1, 256) pattern("^[a-z][a-z0-9_-]*$")

Clauses stack left to right, so text length(1, 256) pattern("^[a-z]...") applies both rules to the same field.

List constraints (on list<T>)

ClauseMeaning
min_items(n)at least n elements
max_items(n)at most n elements
uniqueelements must be distinct (bare keyword, no parentheses)
input labels : list<text> min_items(1) keywords : list<text> max_items(50) unique

A full declaration example

This script exercises every variant base type and every constraint kind — a good reference to copy from. (Adapted from examples/enum_demo.scriptum.)

script "enum_demo" version "0.1.0" enum SparseMode = None | Bm25 | External enum EmbeddingType = Float | Binary | Float16 | BFloat16 | Int8 enum Dimensions = 128 | 256 | 512 | 1024 | 2048 enum Threshold = 0.25 | 0.35 | 0.5 enum HttpStatus : integer = 200 | 201 | 400 | 403 | 404 | 500 enum ApiVersion : text = "v1" | "v2" | "v3" input sparse_mode : SparseMode = None embedding_type : EmbeddingType = Float dimensions : Dimensions = 1024 api_version : ApiVersion = "v1" collection_name : text length(1, 256) artifact_id : text length(1, 256) pattern("^[a-z][a-z0-9_-]*$") labels : list<text> min_items(1) box_threshold : number range(0.0, 1.0) = 0.35 text_threshold : number range(0.0, 1.0) = 0.25 top_k : number range(1, 1000) = 10 padding : number min(0) = 0 output status : text artifact_id : text total_objects : integer min(0) emit "Done" status = "ok" artifact_id = artifact_id total_objects = 0

The constraints (and enums) on these fields all become part of the ScriptContract — the runtime validates supplied inputs against them when a thread is created. See File Structure & Declarations for how the contract is assembled, and Expressions & References for how typed bindings flow through the body.