Comparisons
You can compare two values for equality, and order via the typical operators, like ==, !=, <, <=, > and >=.
For example, interface.mtu == 1000 and 1000 < interface.mtu are valid expressions.
The order of items that have the same type (used by < and other relational operators) is as follows:
- Numbers: numerical order. For example,
1is less than2 - Strings: alphabetical order. For example,
"ac"is less than"bb". - Booleans:
falseis less thantrue. - IP addresses: numerically. For example,
ipAddress("1.2.3.4")is less thanipAddress("1.2.4.5"). - IP subnets: ordered by prefix length first. For subnets with equal prefix lengths, the subnets are ordered
numerically by host part. For example,
ipSubnet("1.2.3.4/24")is less thanipSubnet("1.2.3.4/25"), but greater thanipSubnet("1.2.3.3/24). - MAC addresses: ordered numerically. For example,
macAddress("11:22:33:44:88:99")is less thanmacAddress("11:22:33:44:66:77"). - Date: chronological order. For example,
2000-01-01is before2000-01-02 - Timestamp: chronological order. For example,
2000-01-01T00:00:00Zis before2000-01-01T00:00:01Z - Duration: numerically. For example,
1second is less than2seconds. - Lists: ordered lexicographically; for example
[1, 4]is less than[2, 3]. - Records: two records are ordered lexicographically based on their field values, with fields compared in order of
alphabetically increasing field name. For example
{x: 1, z: "b"}is less than{x: 2, z: "a"}, but is greater than{x: 1, z: "a"}. - OneOfs: two OneOf values are compared based on alphabetical order of their alternative names. For
example,
AdminStatus.DOWNis less thanAdminStatus.UP. If the two values have the same alternative, then they are ordered based on the ordering of any values they contain. - A null value is less than all other values (except itself, to which it is equal).