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

function: Support Type-Based Validation with Argument Position Data #893

Closed
bflad opened this issue Dec 18, 2023 · 1 comment · Fixed by #968
Closed

function: Support Type-Based Validation with Argument Position Data #893

bflad opened this issue Dec 18, 2023 · 1 comment · Fixed by #968
Labels
enhancement New feature or request

Comments

@bflad
Copy link
Contributor

bflad commented Dec 18, 2023

Module version

v1.5.0 (not yet released)

Use-cases

Provider developers can create reusable custom types either in their provider codebases or as a shared Go module, such as terraform-plugin-framework-jsontypes. One nice benefit of a custom type is the ability to support type-based validation, meaning that any usage of that custom type in a schema automatically will perform the validation logic. This saves developers time and repetitive lines of code, such as declaring validators on each attribute definition.

When the type-based validation support was introduced, it was done in a manner that was using the lower-level type system (tftypes.Value) and very schema-specific (path.Path). This was documented as sub-optimal in #589 when the framework v1.0.0 was being released, but was not handled prior due to time.

While the usage of tftypes.Value would be okay for the upcoming provider-defined function support, the path.Path usage is invalid since function argument information in diagnostics is very different. The custom type Validate method is called, however the path.Path passed is always errant since there is no schema-based path information for function arguments.

Proposal

Once #589 is sorted, add the updated type-based validation bits to internal/fromproto5.ArgumentsData() and internal/fromproto6.ArgumentsData() where it appropriately sets the function argument position for the validation request.

References

@bflad bflad added the enhancement New feature or request label Dec 18, 2023
@bflad bflad changed the title function: Support Type-Based Validation function: Support Type-Based Validation with Function Argument Position Data Dec 18, 2023
@bflad bflad changed the title function: Support Type-Based Validation with Function Argument Position Data function: Support Type-Based Validation with Argument Position Data Dec 18, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant