How to access variable from condition

Hi,

I want to be able to access a local variable from a condition block. Is this possible? I’m on tf13.

I’m trying to do something similar to this:

locals {
  types = [
    "type1",
    "type2",
    "type3"
  ]
}

variable "myvar" {
  type        = list(map(string))
  default     = []

  validation {
    condition = length([
        for x in var.myvar:
            true if contains(locals.types, lookup(x, "type", "type1"))
    ]) == length(var.myvar)
    error_message = "Invalid type - see locals.types for valid values."
  }
}

Thanks
Sid