-
Notifications
You must be signed in to change notification settings - Fork 13
all: Implement function parameter validation interfaces #238
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
SBGoods
approved these changes
Oct 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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