Skip to content

Commit 2f458f6

Browse files
authored
chore(docs): add more comparison examples (vectordotdev#18333)
* chore(docs): add more comparison examples * mention match function * remove one test case because it doesn't compile
1 parent 9b4625c commit 2f458f6

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

website/cue/reference/remap/expressions/comparison.cue

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package metadata
22

33
remap: expressions: comparison: {
4-
title: "Comparison"
4+
title: "Comparison"
55
description: """
66
A _comparison_ expression compares two expressions (operands) and produces a Boolean as defined by the
7-
operator.
7+
operator. Please refer to the [match function](\(urls.vrl_match_function)) for matching a string against a regex.
88
"""
99
return: """
1010
Returns a Boolean as defined by the operator.
@@ -39,19 +39,41 @@ remap: expressions: comparison: {
3939

4040
examples: [
4141
{
42-
title: "Equal"
42+
title: "Equal integers"
4343
source: #"""
4444
1 == 1
4545
"""#
4646
return: true
4747
},
48+
{
49+
title: "Equal integer and float"
50+
source: #"""
51+
1 == 1.0
52+
"""#
53+
return: true
54+
},
4855
{
4956
title: "Not equal"
5057
source: #"""
5158
1 != 2
5259
"""#
5360
return: true
5461
},
62+
{
63+
title: "Equal string"
64+
source: #"""
65+
x = "foo"
66+
x == "foo"
67+
"""#
68+
return: true
69+
},
70+
{
71+
title: "Not equal strings"
72+
source: #"""
73+
"foo" != "bar"
74+
"""#
75+
return: true
76+
},
5577
{
5678
title: "Greater than or equal"
5779
source: #"""

website/cue/reference/remap/functions/match.cue

+7
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,12 @@ remap: functions: match: {
3131
"""
3232
return: true
3333
},
34+
{
35+
title: "String does not match the regular expression"
36+
source: """
37+
match("I'm a little teapot", r'.*balloon')
38+
"""
39+
return: false
40+
},
3441
]
3542
}

website/cue/reference/urls.cue

+1
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ urls: {
635635
vrl_features: "\(vrl_reference)/#features"
636636
vrl_functions: "\(vrl_reference)/functions"
637637
vrl_literals: "\(vrl_expressions)/#literal-expressions"
638+
vrl_match_function: "\(vrl_functions)/#match"
638639
vrl_parsing_functions: "\(vrl_functions)/#parse-functions"
639640
vrl_path_expressions: "\(vrl_expressions)#path"
640641
vrl_performance: "\(vrl_reference)#performance"

0 commit comments

Comments
 (0)