-
Notifications
You must be signed in to change notification settings - Fork 12
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
stringvalidator: Support json string validation #86
Comments
Hi @k-yomo 👋 Thank you for raising this feature request. While it technically would not be difficult to implement this validator in this Go module, an intention of terraform-plugin-framework's extensible type system is to allow provider developers, or the ecosystem at large, to create custom types that can cover specific use cases. Otherwise, this Go module could wind up trying to cover an extremely broad area of all possible string encodings, formats, etc. which is unmaintainable for one project. Ideally a custom JSON string type with validation baked into it would be created rather than requiring provider developers to separately implement the JSON validation. Future iterations on that concept would help handle syntactical versus semantic equality, which will help prevent Terraform errors or reported drift in cases where inconsequential whitespace differences can occur. We are hoping to have an initial prototype of this done early next month. |
Thank you for the comment! It sounds great and can't wait it!! |
A new github.com/hashicorp/terraform-plugin-framework-jsontypes Go module is now available with a custom type implementation for JSON strings. The types there perform JSON validation automatically and the normalized type supports ignoring differences in whitespace and property ordering (per the JSON specification). If you can, please give it a try and let us know how it goes. If you would like additional documentation on using custom types, please refer to the custom types documentation. Thanks so much. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform CLI and Framework Versions
❯ terraform version
Terraform v1.3.6
on darwin_arm64
...
❯ go list -m github.com/hashicorp/terraform-plugin-framework
github.com/hashicorp/terraform-plugin-framework v1.0.0
Use Cases
Proposal
It would be very handy if we have json string validator in this package to validate if the given string is valid json or not.
Additional Information
Equivalent implementation in terraform-plugin-sdk package
https://github.com/hashicorp/terraform-plugin-sdk/blob/aa73507131cb35683a6408b4d06252991fecb868/helper/validation/strings.go#L209-L222
Code of Conduct
The text was updated successfully, but these errors were encountered: