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

feat: add validation function for string length in bytes with min and max constraints #1350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akhn1004
Copy link

@akhn1004 akhn1004 commented Jun 5, 2024

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.

@akhn1004 akhn1004 requested a review from a team as a code owner June 5, 2024 16:49
Copy link

CLA assistant check

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.

@yutachaos
Copy link

yutachaos commented Oct 14, 2024

@akhn1004
Your PR is looks good.But looks like you hasn't signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants