terraform-plugin-framework
terraform-plugin-framework copied to clipboard
Add parameter-based provider-defined function validation
Closes: #894
Background
Provider-defined functions can accept parameters, or arguments as input. There is an opportunity to provide validation of such parameters in an analogous manner to the validation of values supplied in configuration for attributes, by implementing parameter-based and type-based validation for provider-defined function parameters.
This PR is concerned with the addition of parameter-based validation, which enables provider developers to define custom validators on framework-provided type parameters or on custom parameters.
<Type>Validator
Interfaces
This PR adds various <Type>Validator
interfaces for custom validators to implement for parameter-based validation
type BoolValidator interface {
Validate(context.Context, BoolRequest, *BoolResponse)
}
type BoolRequest struct {
ArgumentPosition int64
Value types.Bool
}
type BoolResponse struct {
Error *FuncError
}
ParameterWith<Type>Validators
Interfaces
This PR adds various ParameterWith<Type>Validators
interfaces for custom parameter types to implement to enable parameter-based validation
type ParameterWithBoolValidators interface {
Parameter
BoolValidators() []BoolValidator
}