diff --git a/internal/services/privatedns/private_dns_a_record_resource.go b/internal/services/privatedns/private_dns_a_record_resource.go index 999cff623e0b..b7702386be87 100644 --- a/internal/services/privatedns/private_dns_a_record_resource.go +++ b/internal/services/privatedns/private_dns_a_record_resource.go @@ -7,9 +7,9 @@ import ( "github.com/Azure/azure-sdk-for-go/services/privatedns/mgmt/2018-09-01/privatedns" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/privatedns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/privatedns/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -40,7 +40,7 @@ func resourcePrivateDnsARecord() *pluginsdk.Resource { Required: true, ForceNew: true, // lower-cased due to the broken API https://github.com/Azure/azure-rest-api-specs/issues/6641 - ValidateFunc: validate.PrivateDnsARecordName, + ValidateFunc: validate.LowerCasedString, }, // TODO: make this case sensitive once the API's fixed https://github.com/Azure/azure-rest-api-specs/issues/6641 @@ -54,6 +54,7 @@ func resourcePrivateDnsARecord() *pluginsdk.Resource { "records": { Type: pluginsdk.TypeSet, Required: true, + MaxItems: 20, Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, Set: pluginsdk.HashString, }, diff --git a/internal/services/privatedns/validate/private_dns_a_record_name.go b/internal/services/privatedns/validate/private_dns_a_record_name.go deleted file mode 100644 index 77cb68f4ddd0..000000000000 --- a/internal/services/privatedns/validate/private_dns_a_record_name.go +++ /dev/null @@ -1,18 +0,0 @@ -package validate - -import ( - "fmt" - "strings" - - "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" -) - -func PrivateDnsARecordName(i interface{}, k string) (warnings []string, errors []error) { - validate.LowerCasedString(i, k) - - if strings.ContainsAny(i.(string), "@") { - return nil, []error{fmt.Errorf("%q cannot contain @", k)} - } - - return nil, nil -} diff --git a/internal/services/privatedns/validate/private_dns_a_record_name_test.go b/internal/services/privatedns/validate/private_dns_a_record_name_test.go deleted file mode 100644 index d8998dda06e9..000000000000 --- a/internal/services/privatedns/validate/private_dns_a_record_name_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package validate - -import "testing" - -func TestPrivateDnsARecordName(t *testing.T) { - cases := []struct { - Value string - TestName string - ErrCount int - }{ - { - Value: "@", - TestName: "At", - ErrCount: 1, - }, - } - - for _, tc := range cases { - t.Run(tc.TestName, func(t *testing.T) { - _, errors := PrivateDnsARecordName(tc.Value, tc.TestName) - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected NoEmptyStrings to have %d not %d errors for %q", tc.ErrCount, len(errors), tc.TestName) - } - }) - } -}