Skip to content
/ go-cty Public

Commit 6854da9

Browse files
stdlib: ContainsFunc allows testing for presence of null value
The defaults for what to allow in a function argument are intentionally conservative so that function implementations don't all need to reimplement similar validation code for commonly-rejected cases, but this function doesn't do anythign with the "value" argument except compare it with another value using Value.Equals and so null values can be permitted here for the same reason that EqualFunc allows its operands to be null.
1 parent ddb73de commit 6854da9

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# 1.18.1 (Unreleased)
22

3+
- stdlib: `ContainsFunc` now allows its second argument to be null, to test whether the given collection contains any null elements.
34

45
# 1.18.0 (February 23, 2026)
56

cty/function/stdlib/collection.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ var ContainsFunc = function.New(&function.Spec{
321321
Type: cty.DynamicPseudoType,
322322
},
323323
{
324-
Name: "value",
325-
Type: cty.DynamicPseudoType,
324+
Name: "value",
325+
Type: cty.DynamicPseudoType,
326+
AllowNull: true,
326327
},
327328
},
328329
Type: function.StaticReturnType(cty.Bool),

0 commit comments

Comments
 (0)