Reusable validation functions for Terraform, built with the latest Terraform Plugin Framework.
ValidateFX lets you write cleaner, more expressive validations using functions like email, uuid, base64, and more. Use the assert function to validate conditions with custom error messages.
terraform {
required_providers {
validatefx = {
source = "The-DevOps-Daily/validatefx"
version = "0.1.0"
}
}
}
provider "validatefx" {}
variable "email" {
type = string
}
locals {
# Validate email with custom error message
email_check = provider::validatefx::assert(
provider::validatefx::email(var.email),
"Invalid email address provided!"
)
# Or use in variable validation
age_validation = provider::validatefx::assert(
var.user_age >= 18,
"User must be at least 18 years old!"
)
}git clone https://github.com/The-DevOps-Daily/terraform-provider-validatefx.git
cd terraform-provider-validatefx
go mod tidy
make build
make install
make devExample usage in examples/basic/main.tf.
| Function | Description |
|---|---|
all_valid |
Return true when all provided validation checks evaluate to true. |
any_valid |
Return true when any provided validation check evaluates to true. |
assert |
Assert a condition with a custom error message. |
base64 |
Validate that a string is Base64 encoded. |
credit_card |
Validate that a string is a credit card number using the Luhn algorithm. |
domain |
Validate that a string is a compliant domain name. |
email |
Validate that a string is an RFC 5322 compliant email address. |
ip |
Validate that a string is a valid IPv4 or IPv6 address. |
json |
Validate that a string decodes to a JSON object. |
matches_regex |
Validate that a string matches a provided regular expression. |
phone |
Validate that a string is an E.164 compliant phone number. |
semver |
Validate that a string follows Semantic Versioning (SemVer 2.0.0). |
url |
Validate that a string is an HTTP(S) URL. |
uuid |
Validate that a string is an RFC 4122 UUID (versions 1-5). |
version |
Return the provider version string. |
Open to PRs! Good first issues include adding new validators like is_hostname, cidr, or mac_address.
MIT © 2025 DevOps Daily