hashicorp / terraform-plugin-framework-validators

Common Use Case Validators for terraform-plugin-framework
Mozilla Public License 2.0
25 stars 11 forks source link

Consider Per-Type NotNull/Required Validators #185

Open bflad opened 8 months ago

bflad commented 8 months ago

Terraform CLI and Framework Versions

Any Terraform or terraform-plugin-framework version.

Use Cases or Problem Statement

There are cases with nested attributes where setting the parent attribute as Computed: true and any underlying attributes to Required: true is invalid. The framework should likely be raising a sort of implementation error in this situation, which might occur in the future. In these cases, the developer should mark those Required: true underlying attributes as Optional: true and Computed: true, but then they need introduce validation similar to Required: true which is not provided out of the by the framework or this Go module. That attribute flag just checks that the configuration value is not null if the attribute's containing object is present.

Proposal

Introduce NotNull/Required validators into the following packages of this Go module:

After this is potentially merged and released, the framework implementation error can be introduced and the framework documentation needs to be updated to highlight the necessary schema changes and these validators for that situation.

Additional Information

Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/898

Code of Conduct