Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nice to have: Generic way to assert if value is a primitive type #57

Open
alexsomesan opened this issue Feb 1, 2021 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@alexsomesan
Copy link
Member

When implementing recursive traversal functions, I find myself repeatedly doing checks like:

var val tftypes.Value
...
if val.Is(tftypes.String) || val.Is(tftypes.Number) || val.Is(tftypes.Bool) || val.Is(tftypes.DynamicPseudoType) {
  // no more recursion - do stuff with value and return
}
// Implement recursion for complex types

It would be great to have a more concise way to check if the value is a primitive.
I guess I'm suggesting something like:

func (val *Value ) IsPrimitve() bool {
  return val.Is(tftypes.String) || val.Is(tftypes.Number) || val.Is(tftypes.Bool) || val.Is(tftypes.DynamicPseudoType)
}
@bflad bflad added the enhancement New feature or request label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants