How can we test the condition for two different variables in terraform?

I have to add the condition like for the given subscription, the related environment is stg or prod only. I should fail if for the given subscription is deploying into dev.
I have tried to add the validate block in var.tf, but the scope of particular variable is to the block itself.
validation {
condition = (var.subscription_id = "XXX" ? contains(["stg", "prd"], var.env) : contains(["dev", "stg", "prd"], var.env))
error_message = "The environment must be stg or prd."
}
This code throwing error as follows:
Error: Invalid variable validation condition
on vars.tf line 15, in variable "env":
15: condition = (var.subscription_id = "XXX" ? contains(["stg", "prd"], var.env) : contains(["dev", "stg", "prd"], var.env))
The condition for variable "env" must refer to var.env in order to test
incoming values.
Error: Invalid reference in variable validation
on vars.tf line 15, in variable "env":
15: condition = (var.subscription_id = "XXX" ? contains(["stg", "prd"], var.env) : contains(["dev", "stg", "prd"], var.env))
The condition for variable "env" can only refer to the variable itself, using
var.env.