Skip to content

Commit d32617d

Browse files
ewbankkitappilon
authored andcommitted
Changes after review.
1 parent b4fda75 commit d32617d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

helper/validation/map.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ import (
1313
// is of type map and the length of all keys are between min and max (inclusive)
1414
func MapKeyLenBetween(min, max int) schema.SchemaValidateDiagFunc {
1515
return func(v interface{}, path cty.Path) diag.Diagnostics {
16+
var diags diag.Diagnostics
17+
1618
for key := range v.(map[string]interface{}) {
1719
len := len(key)
1820
if len < min || len > max {
19-
return diag.Diagnostics{{
21+
diags = append(diags, diag.Diagnostic{
2022
Severity: diag.Error,
21-
Summary: fmt.Sprintf("expected the length of all keys to be in the range (%d - %d)", min, max),
22-
Detail: fmt.Sprintf("length = %d", len),
23+
Summary: "Bad key length",
24+
Detail: fmt.Sprintf("Key length should be in the range (%d - %d): %s (length = %d)", min, max, key, len),
2325
AttributePath: append(path, cty.IndexStep{Key: cty.StringVal(key)}),
24-
}}
26+
})
27+
break
2528
}
2629
}
2730

28-
return nil
31+
return diags
2932
}
3033
}
3134

0 commit comments

Comments
 (0)