I've used the Any validator but the error messages that occur are not intuitive for a user. In my case, I've passed 2 possibilities to match and failing to match them shows 2 individual errors for the same line without any indication they are related except for the line number. It's a confusing enough experience that I will instead likely create a custom validator.
Proposal
One option that may be straightforward to accommodate is to allow passing a custom error message for the Any block that would override an error from one of the validators in the list.
Another option would be to generate a new single error using text appropriate to the Any validator. For example:
Attribute my_attr value did not satisfy any of "value must be one of: ["alternate"]" or "must match UUID format", got: ""...
Terraform CLI and Framework Versions
Terraform v1.5.7 on darwin_amd64
github.com/hashicorp/terraform-plugin-framework v1.6.1
Use Cases or Problem Statement
I've used the Any validator but the error messages that occur are not intuitive for a user. In my case, I've passed 2 possibilities to match and failing to match them shows 2 individual errors for the same line without any indication they are related except for the line number. It's a confusing enough experience that I will instead likely create a custom validator.
Proposal
One option that may be straightforward to accommodate is to allow passing a custom error message for the Any block that would override an error from one of the validators in the list.
Another option would be to generate a new single error using text appropriate to the Any validator. For example:
Attribute my_attr value did not satisfy any of "value must be one of: ["alternate"]" or "must match UUID format", got: ""...
Additional Information
I see that this is currently expected behavior as exhibited by the test here: this output in the test here: https://github.com/hashicorp/terraform-plugin-framework-validators/blob/main/stringvalidator/any_test.go#L35-L45
Code of Conduct