Skip to content

Commit 95d218d

Browse files
committed
updated implementation for StrMaxLength
1 parent 9000a9f commit 95d218d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

okta/utils/utils.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,14 +715,16 @@ func LinksValue(links interface{}, keys ...string) string {
715715
return LinksValue(l[keys[0]], keys[1:]...)
716716
}
717717

718+
// StrMaxLength updated implementation to count runes instead of bytes (https://github.com/okta/terraform-provider-okta/issues/2396)
718719
func StrMaxLength(max int) schema.SchemaValidateDiagFunc {
719720
return func(i interface{}, k cty.Path) diag.Diagnostics {
720721
v, ok := i.(string)
721722
if !ok {
722723
return diag.Errorf("expected type of %s to be string", k)
723724
}
724-
if len(v) > max {
725-
return diag.Errorf("%s cannot be longer than %d characters", k, max)
725+
runes := []rune(v)
726+
if len(runes) > max {
727+
return diag.Errorf("%s cannot be longer than %d runes", k, max)
726728
}
727729
return nil
728730
}

0 commit comments

Comments
 (0)