diff --git a/website/pages/partials/from-1.5/variables/custom-validation.mdx b/website/pages/partials/from-1.5/variables/custom-validation.mdx index 0da062710..42af7e1d7 100644 --- a/website/pages/partials/from-1.5/variables/custom-validation.mdx +++ b/website/pages/partials/from-1.5/variables/custom-validation.mdx @@ -22,7 +22,7 @@ The expression can refer only to the variable that the condition applies to, and _must not_ produce errors. If the failure of an expression is the basis of the validation decision, use -[the `can` function](./functions/can.html) to detect such errors. For example: +[the `can` function](/docs/from-1.5/functions/conversion/can) to detect such errors. For example: ```hcl variable "image_id" { @@ -59,6 +59,11 @@ variable "image_metadata" { error_message = "The image_metadata.key field must be more than 4 runes." } + validation { + condition = can(var.image_metadata.something.foo) + error_message = "The image_metadata.something.foo field must exist." + } + validation { condition = substr(var.image_metadata.something.foo, 0, 3) == "bar" error_message = "The image_metadata.something.foo field must start with \"bar\"."