Skip to content

Commit

Permalink
Merge pull request #28 from chriswvu/PC-1391-input-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lorengordon authored Nov 27, 2024
2 parents 81589c8 + f8788ff commit cd15337
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.0
current_version = 1.0.1
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### [1.0.1] (https://github.com/plus3it/terraform-aws-tardigrade-account-alternate-contacts/releases/tag/1.0.1)

**Released**: 2024.11.27

**Summary**:

* Adds variable validation

### [1.0.0] (https://github.com/plus3it/terraform-aws-tardigrade-account-alternate-contacts/releases/tag/1.0.0)

**Released**: 2023.02.09
Expand Down
34 changes: 34 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,38 @@ variable "account_alternate_contacts" {
phone_number = string
}))
})
validation {
condition = alltrue([
for type in var.account_alternate_contacts :
length(type.name) >= 1 &&
length(type.name) <= 64
])
error_message = "Invalid value for Name (must be between 1 and 64 characters)"
}
validation {
condition = alltrue([
for type in var.account_alternate_contacts :
length(type.title) >= 1 &&
length(type.title) <= 50
])
error_message = "Invalid value for Title (must be between 1 and 50 characters)"
}
validation {
condition = alltrue([
for type in var.account_alternate_contacts :
length(type.email_address) >= 1 &&
length(type.email_address) <= 254 &&
can(regex("^[\\s]*[\\w+=.#|!&-]+@[\\w.-]+\\.[\\w]+[\\s]*$", type.email_address))
])
error_message = "Invalid value for email address (must be between 1 and 50 characters and correct syntax)"
}
validation {
condition = alltrue([
for type in var.account_alternate_contacts :
length(type.phone_number) >= 1 &&
length(type.phone_number) <= 25 &&
can(regex("^[\\s0-9()+-]+$", type.phone_number))
])
error_message = "Invalid value for phone number (must be between 1 and 50 characters and correct syntax)"
}
}

0 comments on commit cd15337

Please sign in to comment.