Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for mapping between SDKv2 and the Framework #660

Merged
merged 8 commits into from
Feb 10, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ the Framework documentation for details. Refer to the
[Attributes - Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) page in this guide to learn how to
implement custom validators.

The following table describes the mapping between predefined validators in SDKv2 and the Framework. You should use an
attribute validator for [per-attribute validation](/plugin/framework/validation#attribute-validation), or a
[data source validator](/plugin/framework/data-sources/validate-configuration),
[provider validator](plugin/framework/providers/validate-configuration) or
[resource validator](/plugin/framework/resources/validate-configuration) for declaring validation at the level of the
data source, provider or resource, respectively.

| SDK Attribute Field | Framework Attribute Validator | Framework Data Source, Provider and Resource Validators |
|---------------------|---------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| AtLeastOneOf | {TYPE}validator.AtLeastOneOf() | [datasourcevalidator.AtLeastOneOf()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator#AtLeastOneOf), [providervalidator.AtLeastOneOf()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/providervalidator#AtLeastOneOf), [resourcevalidator.AtLeastOneOf()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator#AtLeastOneOf) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would some html be useful here to have a list for the cases where there are several translation available: https://stackoverflow.com/questions/19950648/how-to-write-lists-inside-a-markdown-table

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how well our Markdown rendering engine for the website plays with intermixed HTML/Markdown syntax. Another option here could be having separate table columns for data source, provider, and resource to prevent the listing in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have split into 3 columns for data source, provider and resource.

| ConflictsWith | {TYPE}validator.ConflictsWith() | [datasourcevalidator.Conflicting()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator#Conflicting), [providervalidator.Conflicting()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/providervalidator#Conflicting), [resourcevalidator.Conflicting()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator#Conflicting) |
| ExactlyOneOf | {TYPE}validator.ExactlyOneOf() | [datasourcevalidator.ExactlyOneOf()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator#ExactlyOneOf), [providervalidator.ExactlyOneOf()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/providervalidator#ExactlyOneOf), [resourcevalidator.ExactlyOneOf()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator#ExactlyOneOf) |
| RequiredWith | {TYPE}validator.AlsoRequires() | [datasourcevalidator.RequiredTogether()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator#RequiredTogether), [providervalidator.RequiredTogether()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/providervalidator#RequiredTogether), [resourcevalidator.RequiredTogether()](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator#RequiredTogether) |

This page explains how to migrate a predefined validator from SDKv2 to the Framework.

## SDKv2
Expand Down