Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better messaging from errors under Any validator #203

Open
1 task done
fantapop opened this issue Mar 20, 2024 · 0 comments
Open
1 task done

Better messaging from errors under Any validator #203

fantapop opened this issue Mar 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@fantapop
Copy link

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

  • I agree to follow this project's Code of Conduct
@fantapop fantapop added the enhancement New feature or request label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant