Skip to content

Variable Validation: allow functions in error_message #24407

@alexjurkiewicz

Description

@alexjurkiewicz

Here's a validation test I wrote for a MySQL username:

validation {
    condition     = length(var.username) > 16
    error_message = "The username cannot be more than 16 characters (first 16 are ${trim(var.username, 0, 16)})."
  }

I wanted to give a hint to the operator about the longest string allowed, to make their life easier. But you can't use functions in error_message. Please add support for the above use-case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    custom-conditionsFeedback on variable validation, preconditions. postconditions, checks, and test assertionsenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions