Open akhn1004 opened 5 months ago
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement
Learn more about why HashiCorp requires a CLA and what the CLA includes
Have you signed the CLA already but the status is still pending? Recheck it.
@akhn1004 Your PR is looks good.But looks like you hasn't signed the CLA.
Summary
Adds a new validation function for validating string lengths in bytes with specified minimum and maximum constraints. The new function,
StringLenBytesBetween
, ensures that the length of a given string falls within the specified byte range.Background
In many cases, especially when dealing with APIs or data storage, it is crucial to validate that string inputs meet specific length requirements to prevent errors and ensure data integrity. The existing validation functions did not provide a way to validate string lengths based on byte count, which is important for handling multi-byte characters correctly.
Related Issue
This issue has been raised in the context of ALB listener rules in Terraform AWS provider, as outlined in hashicorp/terraform-provider-aws#37802. The problem manifests when attempting to set fixed responses with multi-byte characters. For example, Japanese characters, which are typically 2-3 bytes each, quickly exceed the byte limits imposed by ALB, leading to validation errors even though the number of characters might be within acceptable limits.