In
The in constraint restricts a node’s value to a predefined set of allowed
values. It is most commonly used to limit text or numeric nodes to a controlled
vocabulary or a fixed set of constants.
When applied to text nodes, the behavior of this constraint can be influenced by the case sensitivity flag.
Type Matrix
The following table summarizes which node types support the in constraint and
how membership is evaluated.
Node Type |
S |
Value Type |
Details |
|---|---|---|---|
Integer |
ValueList |
Valid only if the integer value appears in the list of integers. |
|
Boolean |
|||
Float |
ValueList |
Valid only if the floating-point value appears in the list. Equality must be evaluated using a platform-consistent strategy (for example, with a tolerance that accounts for IEEE rounding). |
|
Text |
ValueList |
Valid only if the text matches one of the listed text values. |
|
Date |
|||
Time |
|||
DateTime |
|||
Bytes |
ValueList |
Valid only if the byte sequence matches one of the listed byte sequences. |
|
TimeDelta |
|||
RegEx |
|||
Value |
|||
ValueList |
|||
ValueMatrix |
|||
Section |
|||
SectionList |
|||
SectionWithTexts |
|||
NotValidated |
Rules
List Membership: The value of the node must exactly match one of the values listed in
in.Type Alignment: Each value listed in
inmust have the same type as the constrained node.Mixing types (for example, constraining a text node with integers) is invalid and must be rejected by the validator.
No Duplicate Entries: Each value in the
inlist must be unique.Duplicate entries provide no additional meaning and must be treated as an error in the validation rules document.
Floats and Equality: For floating-point values, equality must be determined using a platform-consistent strategy that accounts for precision and rounding behavior.
This ensures that values such as
0.1behave consistently across different validators and platforms.Case Sensitivity: Text comparisons using
inare case-insensitive by default.This behavior can be changed using the
case_sensitiveflag. See The Case Sensitive Flag for details.
Example
The following example restricts mode to one of three predefined text values:
[server.mode]
type: "text"
in: "idle", "scanning", "connecting"
[server]
mode: "scanning"
[server]
mode: "shutdown" # ERROR: Must be one of "idle", "scanning", "connecting"