hashicorp / hashicorp/terraform-plugin-framework

Add `value.IsNullOrUnknown()` function

Open
#1,060 2 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
384
Forks
107
Avg merge
3m
Merged PRs (30d)
1

Description

Does this make sense for checking whether the value has a real value?

I have an optional but non-computed attribute, I usually think I can safely assume the plan will never be an `Unknown` value but am worried about someone change the schema to computed in the future and this can become a side-effect.

Writing `s.IsNull() || s.IsUnknown()` is verbose in provider code, IMO.

```go
func (s StringValue) IsNullOrUnknown() bool {
return s.IsNull() || s.IsUnknown()
}
```

Kind of like `if someAttr, ok := d.GetOk("some_attr"); ok {}` in SDKv2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.