hashicorp / terraform-plugin-framework

A next-generation framework for building Terraform providers.
https://developer.hashicorp.com/terraform/plugin/framework
Mozilla Public License 2.0
284 stars 92 forks source link

Remove deprecated `xatrr.TypeWithValidate` interface #978

Open bendbennett opened 2 months ago

bendbennett commented 2 months ago

Changes in #968 included the deprecation of the xattr.TypeWithValidate interface. As part of the preparation for the release of v2.x of the Framework we should remove the xattr.TypeWithValidate interface and all usages.

A further consideration is the removal of the implementation of xattr.TypeWithValidate from the basetypes Float64Type, Int64Type, ListType, MapType and SetType.

For Float64Type, Int64Type, it may not be necessary to implement the equivalent validation on Float64Value, Int64Value as the calls to <Float64|Int64>Type.ValueFromTerraform ensure that the tftypes.Value supplied can be represented as 64-bit floating point, and integer values, respectively. The constructors on the corresponding value types only accept 64-bit floating point, and integer values too (e.g., NewFloat64Value). So it doesn't seem that there is a way to generate a Float64Value or an Int64Value type that would have a value that couldn't be represented as a 64-bit floating point, or integer value, respectively.

The base types ListType, MapType and SetType also implement xatrr.TypeWithValidate, iterating over their elements and calling Validate() on each. If it is unnecessary to implement validation on Float64Value, Int64Value value types, for the reasons outlined, then it may not be necessary to implement validation on ListValue, MapValue and SetValue types either as the call to <List|Map|Set>Type.ValueFromTerraform will call ValueFromTerraform on each of the elements.

References: