terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
helper/validation: add StringRuneCountBetween() and StringBytesBetween() instead StringLenBetween()
Summary
- In this PullRequest, add validator in order to count
string lengthcorrectly. - Current, StringLenBetween() count
byte length. - For example Japanese, 1 character mean 3 bytes in UTF-8.
- Sometimes, improper validation implements in terraform-provider via this behavior
What's changes?
- add
StringRuneCountBetween()for validate number of characters - add
StringBytesBetween()for validate number of bytes (it's just copy ofStringLenBetween()) StringLenBetween()is to deprecated- add validation for parameters(min, max)
- add test
Related issues
- https://github.com/hashicorp/terraform-provider-aws/issues/19846
- https://github.com/hashicorp/terraform-provider-aws/issues/22949
@bflad Could you help this PR?