Skip to content

Commit

Permalink
Merge pull request #263 from terraform-providers/cosmosdb-name
Browse files Browse the repository at this point in the history
CosmosDB: fixing the validation on the name field
  • Loading branch information
tombuildsstuff authored Aug 22, 2017
2 parents 4ade5d5 + 753bcca commit 4a6f115
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion azurerm/resource_arm_cosmos_db_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func resourceAzureRMCosmosDBAccountFailoverPolicyHash(v interface{}) int {
func validateAzureRmCosmosDBAccountName(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)

r, _ := regexp.Compile("[a-z0-9-]")
r, _ := regexp.Compile("^[a-z0-9\\-]+$")
if !r.MatchString(value) {
errors = append(errors, fmt.Errorf("CosmosDB Account Name can only contain lower-case characters, numbers and the `-` character."))
}
Expand Down
8 changes: 8 additions & 0 deletions azurerm/resource_arm_cosmos_db_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ func TestAccAzureRMCosmosDBAccountName_validation(t *testing.T) {
Value: "abc",
ErrCount: 0,
},
{
Value: "cosmosDBAccount1",
ErrCount: 1,
},
{
Value: "hello-world",
ErrCount: 0,
},
{
Value: str,
ErrCount: 0,
Expand Down

0 comments on commit 4a6f115

Please sign in to comment.