Skip to content

Commit 8b5bca5

Browse files
Merge pull request #998 from Gijsreyn/add-reference-doc-comparison-functions
Add reference doc comparison functions
2 parents e6b4e3e + 0e8610b commit 8b5bca5

File tree

4 files changed

+630
-0
lines changed

4 files changed

+630
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
description: Reference for the 'greater' DSC configuration document function
3+
ms.date: 07/24/2025
4+
ms.topic: reference
5+
title: greater
6+
---
7+
8+
# greater
9+
10+
## Synopsis
11+
12+
Checks whether the first value is greater than the second value.
13+
14+
## Syntax
15+
16+
```Syntax
17+
greater(<firstValue>, <secondValue>)
18+
```
19+
20+
## Description
21+
22+
The `greater()` function checks whether the first value is greater than the second value,
23+
returning `true` if it is and otherwise `false`. You can use this function to compare two
24+
values of the same data type. If the values are different types, like a string and an
25+
integer, DSC returns an error for this function.
26+
27+
For strings, the comparison is case-sensitive and uses lexicographic ordering based on character codes.
28+
29+
## Examples
30+
31+
### Example 1 - Compare two numbers
32+
33+
The following example shows how you can use the function to compare two numbers.
34+
35+
```yaml
36+
# greater.example.1.dsc.config.yaml
37+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
38+
resources:
39+
- name: Compare numbers
40+
type: Microsoft.DSC.Debug/Echo
41+
properties:
42+
output:
43+
firstGreater: "[greater(5, 3)]"
44+
secondGreater: "[greater(3, 5)]"
45+
equalNumbers: "[greater(5, 5)]"
46+
```
47+
48+
```bash
49+
dsc config get --file greater.example.1.dsc.config.yaml
50+
```
51+
52+
```yaml
53+
results:
54+
- name: Compare numbers
55+
type: Microsoft.DSC.Debug/Echo
56+
result:
57+
actualState:
58+
output:
59+
firstGreater: true
60+
secondGreater: false
61+
equalNumbers: false
62+
messages: []
63+
hadErrors: false
64+
```
65+
66+
### Example 2 - Compare two strings
67+
68+
The following example shows how you can use the function to compare two strings.
69+
70+
```yaml
71+
# greater.example.2.dsc.config.yaml
72+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
73+
resources:
74+
- name: Compare strings
75+
type: Microsoft.DSC.Debug/Echo
76+
properties:
77+
output:
78+
lexicographicGreater: "[greater('b', 'a')]"
79+
lexicographicLess: "[greater('a', 'b')]"
80+
caseSensitive: "[greater('a', 'A')]"
81+
```
82+
83+
```bash
84+
dsc config get --file greater.example.2.dsc.config.yaml
85+
```
86+
87+
```yaml
88+
results:
89+
- name: Compare strings
90+
type: Microsoft.DSC.Debug/Echo
91+
result:
92+
actualState:
93+
output:
94+
lexicographicGreater: true
95+
lexicographicLess: false
96+
caseSensitive: true
97+
messages: []
98+
hadErrors: false
99+
```
100+
101+
### Example 3 - Type mismatch error
102+
103+
The following example shows what happens when you try to compare different types.
104+
105+
```yaml
106+
# greater.example.3.dsc.config.yaml
107+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
108+
resources:
109+
- name: Type mismatch
110+
type: Microsoft.DSC.Debug/Echo
111+
properties:
112+
output: "[greater('5', 3)]"
113+
```
114+
115+
```bash
116+
dsc config get --file greater.example.3.dsc.config.yaml
117+
```
118+
119+
This will result in an error because you cannot compare a string with a number.
120+
121+
## Parameters
122+
123+
### firstValue
124+
125+
The first value to compare. Must be the same type as the second value.
126+
127+
```yaml
128+
Type: [number, string]
129+
Required: true
130+
```
131+
132+
### secondValue
133+
134+
The second value to compare. Must be the same type as the first value.
135+
136+
```yaml
137+
Type: [number, string]
138+
Required: true
139+
```
140+
141+
The `greater()` function expects exactly two input values of the same type.
142+
Separate each value with a comma. If the type of the second input value is
143+
different from the first value, DSC returns an error for the function.
144+
145+
String comparisons are case-sensitive and use lexicographic ordering.
146+
147+
## Output
148+
149+
The `greater()` function returns `true` if the first value is greater than
150+
the second value and otherwise `false`.
151+
152+
```yaml
153+
Type: bool
154+
```
155+
156+
<!-- Link reference definitions -->
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
description: Reference for the 'greaterOrEquals' DSC configuration document function
3+
ms.date: 07/24/2025
4+
ms.topic: reference
5+
title: greaterOrEquals
6+
---
7+
8+
# greaterOrEquals
9+
10+
## Synopsis
11+
12+
Checks whether the first value is greater than or equal to the second value.
13+
14+
## Syntax
15+
16+
```Syntax
17+
greaterOrEquals(<firstValue>, <secondValue>)
18+
```
19+
20+
## Description
21+
22+
The `greaterOrEquals()` function checks whether the first value is greater
23+
than or equal to the second value, returning `true` if it is and otherwise `false`.
24+
You can use this function to compare two values of the same data type. If the values
25+
are different types, like a string and an integer, DSC returns an error for this function.
26+
27+
For strings, the comparison is case-sensitive and uses lexicographic ordering based on character codes.
28+
29+
## Examples
30+
31+
### Example 1 - Compare two numbers
32+
33+
The following example shows how you can use the function to compare two numbers.
34+
35+
```yaml
36+
# greaterOrEquals.example.1.dsc.config.yaml
37+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
38+
resources:
39+
- name: Compare numbers
40+
type: Microsoft.DSC.Debug/Echo
41+
properties:
42+
output:
43+
firstGreater: "[greaterOrEquals(5, 3)]"
44+
secondGreater: "[greaterOrEquals(3, 5)]"
45+
equalNumbers: "[greaterOrEquals(5, 5)]"
46+
```
47+
48+
```bash
49+
dsc config get --file greaterOrEquals.example.1.dsc.config.yaml
50+
```
51+
52+
```yaml
53+
results:
54+
- name: Compare numbers
55+
type: Microsoft.DSC.Debug/Echo
56+
result:
57+
actualState:
58+
output:
59+
firstGreater: true
60+
secondGreater: false
61+
equalNumbers: true
62+
messages: []
63+
hadErrors: false
64+
```
65+
66+
### Example 2 - Compare two strings
67+
68+
The following example shows how you can use the function to compare two strings.
69+
70+
```yaml
71+
# greaterOrEquals.example.2.dsc.config.yaml
72+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
73+
resources:
74+
- name: Compare strings
75+
type: Microsoft.DSC.Debug/Echo
76+
properties:
77+
output:
78+
lexicographicGreater: "[greaterOrEquals('b', 'a')]"
79+
lexicographicLess: "[greaterOrEquals('a', 'b')]"
80+
equalStrings: "[greaterOrEquals('a', 'a')]"
81+
caseSensitive: "[greaterOrEquals('Aa', 'aa')]"
82+
```
83+
84+
```bash
85+
dsc config get --file greaterOrEquals.example.2.dsc.config.yaml
86+
```
87+
88+
```yaml
89+
results:
90+
- name: Compare strings
91+
type: Microsoft.DSC.Debug/Echo
92+
result:
93+
actualState:
94+
output:
95+
lexicographicGreater: true
96+
lexicographicLess: false
97+
equalStrings: true
98+
caseSensitive: false
99+
messages: []
100+
hadErrors: false
101+
```
102+
103+
### Example 3 - Type mismatch error
104+
105+
The following example shows what happens when you try to compare different types.
106+
107+
```yaml
108+
# greaterOrEquals.example.3.dsc.config.yaml
109+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
110+
resources:
111+
- name: Type mismatch
112+
type: Microsoft.DSC.Debug/Echo
113+
properties:
114+
output: "[greaterOrEquals('5', 3)]"
115+
```
116+
117+
```bash
118+
dsc config get --file greaterOrEquals.example.3.dsc.config.yaml
119+
```
120+
121+
This will result in an error because you cannot compare a string with a number.
122+
123+
## Parameters
124+
125+
### firstValue
126+
127+
The first value to compare. Must be the same type as the second value.
128+
129+
```yaml
130+
Type: [number, string]
131+
Required: true
132+
```
133+
134+
### secondValue
135+
136+
The second value to compare. Must be the same type as the first value.
137+
138+
```yaml
139+
Type: [number, string]
140+
Required: true
141+
```
142+
143+
The `greaterOrEquals()` function expects exactly two input values of the same type.
144+
Separate each value with a comma. If the type of the second input value is different
145+
from the first value, DSC returns an error for the function.
146+
147+
String comparisons are case-sensitive and use lexicographic ordering.
148+
149+
## Output
150+
151+
The `greaterOrEquals()` function returns `true` if the first value is greater than
152+
or equal to the second value and otherwise `false`.
153+
154+
```yaml
155+
Type: bool
156+
```
157+
158+
<!-- Link reference definitions -->

0 commit comments

Comments
 (0)