@@ -8,13 +8,16 @@ import (
88
99 "github.com/hashicorp/terraform-plugin-framework/attr"
1010 "github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
11+ "github.com/hashicorp/terraform-plugin-framework/internal/fwschema/fwxschema"
12+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
1113 "github.com/hashicorp/terraform-plugin-framework/types"
1214 "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1315)
1416
1517// Ensure the implementation satisifies the desired interfaces.
1618var (
17- _ Attribute = DynamicAttribute {}
19+ _ Attribute = DynamicAttribute {}
20+ _ fwxschema.AttributeWithDynamicValidators = DynamicAttribute {}
1821)
1922
2023// DynamicAttribute represents a schema attribute that is a dynamic, rather
@@ -90,6 +93,18 @@ type DynamicAttribute struct {
9093 // - https://github.com/hashicorp/terraform/issues/7569
9194 //
9295 DeprecationMessage string
96+
97+ // Validators define value validation functionality for the attribute. All
98+ // elements of the slice of AttributeValidator are run, regardless of any
99+ // previous error diagnostics.
100+ //
101+ // Many common use case validators can be found in the
102+ // github.com/hashicorp/terraform-plugin-framework-validators Go module.
103+ //
104+ // If the Type field points to a custom type that implements the
105+ // xattr.TypeWithValidate interface, the validators defined in this field
106+ // are run in addition to the validation defined by the type.
107+ Validators []validator.Dynamic
93108}
94109
95110// ApplyTerraform5AttributePathStep always returns an error as it is not
@@ -168,3 +183,8 @@ func (a DynamicAttribute) IsRequiredForImport() bool {
168183func (a DynamicAttribute ) IsOptionalForImport () bool {
169184 return false
170185}
186+
187+ // DynamicValidators returns the Validators field value.
188+ func (a DynamicAttribute ) DynamicValidators () []validator.Dynamic {
189+ return a .Validators
190+ }
0 commit comments