Skip to content

Commit

Permalink
chore(docs): add more comparison examples (vectordotdev#18333)
Browse files Browse the repository at this point in the history
* chore(docs): add more comparison examples

* mention match function

* remove one test case because it doesn't compile
  • Loading branch information
pront authored Aug 22, 2023
1 parent 9b4625c commit 2f458f6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
28 changes: 25 additions & 3 deletions website/cue/reference/remap/expressions/comparison.cue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package metadata

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

examples: [
{
title: "Equal"
title: "Equal integers"
source: #"""
1 == 1
"""#
return: true
},
{
title: "Equal integer and float"
source: #"""
1 == 1.0
"""#
return: true
},
{
title: "Not equal"
source: #"""
1 != 2
"""#
return: true
},
{
title: "Equal string"
source: #"""
x = "foo"
x == "foo"
"""#
return: true
},
{
title: "Not equal strings"
source: #"""
"foo" != "bar"
"""#
return: true
},
{
title: "Greater than or equal"
source: #"""
Expand Down
7 changes: 7 additions & 0 deletions website/cue/reference/remap/functions/match.cue
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,12 @@ remap: functions: match: {
"""
return: true
},
{
title: "String does not match the regular expression"
source: """
match("I'm a little teapot", r'.*balloon')
"""
return: false
},
]
}
1 change: 1 addition & 0 deletions website/cue/reference/urls.cue
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ urls: {
vrl_features: "\(vrl_reference)/#features"
vrl_functions: "\(vrl_reference)/functions"
vrl_literals: "\(vrl_expressions)/#literal-expressions"
vrl_match_function: "\(vrl_functions)/#match"
vrl_parsing_functions: "\(vrl_functions)/#parse-functions"
vrl_path_expressions: "\(vrl_expressions)#path"
vrl_performance: "\(vrl_reference)#performance"
Expand Down

0 comments on commit 2f458f6

Please sign in to comment.