There's a new feature in terraform 1.9 that can help here, a variable validation can now refer to another variable: https://github.com/hashicorp/terraform/blob/v1.9/CHANGELOG.md#190-june-26-2024