You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
bflad
changed the title
function: Support Type-Based Validation
function: Support Type-Based Validation with Function Argument Position Data
Dec 18, 2023
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
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.
Module version
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, thepath.Path
usage is invalid since function argument information in diagnostics is very different. The custom typeValidate
method is called, however thepath.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()
andinternal/fromproto6.ArgumentsData()
where it appropriately sets the function argument position for the validation request.References
The text was updated successfully, but these errors were encountered: