Equals

The equals constraint requires a node to have an exact value or size. While it may appear simple at first glance, equals becomes particularly powerful when combined with alternatives.

Typical use cases include:

  • constraining a node to a single, fixed value,

  • enforcing an exact length or size, and

  • combining strict matches with more flexible alternatives.

When applied to text values, equals can be influenced by the case sensitivity setting.

Type Matrix

The following table summarizes how equals behaves for different node types.

Node Type

S

Value Type

Details

Integer

Integer

Constrains the integer value to the given constant.

Boolean

Boolean

Constrains the boolean value to the given constant.

Float

Float

Constrains the floating-point value to the given constant. Equality must be evaluated using a platform-consistent strategy (for example, with a tolerance that accounts for IEEE rounding).

Text

Text
Integer

If a text value is given, constrains the node to that exact text. If an integer is given, constrains the text length in Unicode code points.

Date

Time

DateTime

Bytes

Bytes
Integer

If a byte sequence is given, constrains the value to that exact sequence. If an integer is given, constrains the length of the byte sequence.

TimeDelta

RegEx

Value

ValueList

Integer

Constrains the list to exactly n elements.

ValueMatrix

ValueList

Constrains the matrix to exactly n rows and m columns. The first integer applies to rows, the second to columns.

Section

Integer

Constrains the number of child entries when using vr_any.

SectionList

Integer

Constrains the section list to exactly n entries.

SectionWithTexts

Integer

Constrains the number of child entries when using vr_any.

NotValidated

Rules

  1. Exact Match Required: The value or size of the node must be exactly equal to the value specified by equals.

  2. Type Alignment for Scalar Types: For scalar values, the type of the equals value must match the node type.

  3. Text and Bytes Length Special Case: If an integer is used with a text or bytes node, the constraint applies to the number of Unicode code points or bytes, respectively—not to the exact content.

  4. List and Matrix Scope: For lists and matrices, equals constrains the number of elements, rows, or columns, not their contents.

  5. Floats and Equality: For floating-point values, equality must be determined using a platform-consistent strategy that accounts for precision and rounding issues.

    For example, equals: 0.1 must behave consistently across validators even if floating-point representations differ internally.

  6. Case Sensitivity: Text comparisons using equals are case-insensitive by default.

    This behavior can be changed using the case_sensitive flag. See The Case Sensitive Flag for details.

Examples

Numeric Example

In the following example, header must contain exactly five bytes:

[message.header]
type: "bytes"
equals: 5

Alternatives Example

In this example, allowed_action may either reference a valid action_id key defined elsewhere in the document, or be the literal asterisk *.

The equals constraint enables the second case:

*[app.allowed_action]*
type: "text"
key: "action_id"

*[app.allowed_action]*
type: "text"
equals: "*"