all: Implement function parameter validation interfaces #238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #235
This PR implements function parameter validation interfaces to all of our common "value-based" validators. Most of the changes are straightforward as the parameter interface only differs from the original because the error handling is different (
diag.Diagnostics
vs.function.FuncError
) and the context provided is different (Config
data andpath
expressions vs.ArgumentPosition
).There are a few exceptions where I didn't implement the parameter interfaces:
IsRequired
- This validator is only useful with blocks, which aren't applicable for provider functions.ExactlyOneOf
,ConflictsWith
, etc.) - these validators can only operate on schema-based data that supports paths, which aren't applicable for provider functions.validator
package interfaces as input (All
,Any
, etc.) - these validators are a little awkward to implement and probably require a little more thought on whether we should duplicate them or just do type assertions internally.All
,Any
, etc.) #239objectvalidator
package - after the above exceptions, there were no value-based validators here to implement.Other Notes
nil
when invalid data was given to create the validator with. This would cause a panic withterraform-plugin-framework
and is undefined behavior (really should return an error, but to keep the API clean, we can't return one)stringvalidator.LengthBetween