terraform-plugin-framework
terraform-plugin-framework copied to clipboard
function: Consider Parameter-Based Validators
Module version
v1.5.0 (not yet released)
Use-cases
Provider developers implementing a schema definition for a data source, resource, or provider can define attribute-based validators to define validation rules that should be ran against configuration values. It might be nice to offer the same for provider-defined function definitions, since each parameter should theoretically be able to do something similar. The main "challenge" here is that the attribute-based validator interfaces and implementations are named relatively towards schemas, e.g. in their package import naming.
Attempted Solutions
Manually implement value validation in provider-defined function logic (Run method), checking the value, adding any diagnostics, and returning early if necessary.
Proposal
Open to suggestions
Double check whether the existing validator interfaces are acceptable to also serve as interfaces for parameter-based validation.
Add Validators fields to function.Parameter implementations. Implement parameter-based validation in internal/fromproto5.ArgumentsData() and internal/fromproto6.ArgumentsData() by looping through the Validators.
References
- #893 (similar-ish; dealing with validation as well)