Starts, Ends and Contains
The starts, ends, and contains constraints validate whether a text value
begins with, ends with, or contains a specified substring.
These constraints provide a lightweight and portable alternative to regular expressions and are often sufficient for enforcing simple naming conventions. They apply only to text values and can be combined with the case sensitivity flag.
Type Matrix
The following table summarizes how these constraints apply to different node types.
Node Type |
S |
Value Type |
Details |
|---|---|---|---|
Integer |
|||
Boolean |
|||
Float |
|||
Text |
Text
ValueList[Text]
|
Constrains the text to start with, end with, or contain one of the specified values. |
|
Date |
|||
Time |
|||
DateTime |
|||
Bytes |
|||
TimeDelta |
|||
RegEx |
|||
Value |
|||
ValueList |
|||
ValueMatrix |
|||
Section |
|||
SectionList |
|||
SectionWithTexts |
|||
NotValidated |
Rules for Starts, Ends and Contains
Starts: The
startsconstraint succeeds if the text begins with the specified substring.[server.identifier] type: "text" starts: "id"
[server] identifier: "id5000" # VALID
Ends: The
endsconstraint succeeds if the text ends with the specified substring.[server.identifier] type: "text" ends: "_id"
[server] identifier: "example_id" # VALID
Contains: The
containsconstraint succeeds if the text includes the specified substring anywhere.The negated form
not_containsensures that the substring does not appear.[server.identifier] type: "text" not_contains: "example"
[server] identifier: "one_example_id" # ERROR: Must not contain "example"
Multiple Values (OR Semantics): If a value list is provided, the constraint is satisfied if the text matches any of the listed values.
[server.identifier] type: "text" starts: "server_", "client_"
[server] identifier: "server_001"
Design Rationale
OR semantics keep these constraints simple and predictable. More complex matching scenarios that require logical AND combinations or pattern grouping should instead be implemented using
matches(regular expressions).Case Sensitivity: By default, comparisons are case-insensitive.
This behavior applies equally to
starts,ends, andcontainsand can be changed using thecase_sensitiveflag. See The Case Sensitive Flag for details.
Example
[api.function]
type: "text"
starts: "fn"
ends: "(x)", "(x,y)"
[api]
function: "fnAdd(x,y)" # VALID
[server]
function: "sub(x)" # ERROR: Must start with "fn"