Skip to content

Commit 5df5ef5

Browse files
committed
Update following code review (#6)
1 parent 3bf8ecc commit 5df5ef5

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

.changelog/6.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:feature
2+
Added `SizeAtLeast()`, `SizeAtMost()` and `SizeBetween` validation functions to `mapvalidator` package
3+
```

mapvalidator/size_at_least.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ func (v sizeAtLeastValidator) Validate(ctx context.Context, req tfsdk.ValidateAt
4444
}
4545
}
4646

47+
// SizeAtLeast returns an AttributeValidator which ensures that any configured
48+
// attribute value:
49+
//
50+
// - Is a Map.
51+
// - Contains at least min elements.
52+
//
53+
// Null (unconfigured) and unknown (known after apply) values are skipped.
4754
func SizeAtLeast(min int) tfsdk.AttributeValidator {
4855
return sizeAtLeastValidator{
4956
min: min,

mapvalidator/size_at_most.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ func (v sizeAtMostValidator) Validate(ctx context.Context, req tfsdk.ValidateAtt
4444
}
4545
}
4646

47+
// SizeAtMost returns an AttributeValidator which ensures that any configured
48+
// attribute value:
49+
//
50+
// - Is a Map.
51+
// - Contains at most max elements.
52+
//
53+
// Null (unconfigured) and unknown (known after apply) values are skipped.
4754
func SizeAtMost(max int) tfsdk.AttributeValidator {
4855
return sizeAtMostValidator{
4956
max: max,

mapvalidator/size_between.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ func (v sizeBetweenValidator) Validate(ctx context.Context, req tfsdk.ValidateAt
4646
}
4747
}
4848

49+
// SizeBetween returns an AttributeValidator which ensures that any configured
50+
// attribute value:
51+
//
52+
// - Is a Map.
53+
// - Contains at least min elements and at most max elements.
54+
//
55+
// Null (unconfigured) and unknown (known after apply) values are skipped.
4956
func SizeBetween(min, max int) tfsdk.AttributeValidator {
5057
return sizeBetweenValidator{
5158
min: min,

0 commit comments

Comments
 (0)