Skip to content

Commit

Permalink
Update following code review (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jun 23, 2022
1 parent afe55e6 commit d6a993c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
Added `SizeAtLeast()`, `SizeAtMost()` and `SizeBetween` validation functions to `setvalidator` package
```
7 changes: 7 additions & 0 deletions setvalidator/size_at_least.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func (v sizeAtLeastValidator) Validate(ctx context.Context, req tfsdk.ValidateAt
}
}

// SizeAtLeast returns an AttributeValidator which ensures that any configured
// attribute value:
//
// - Is a Set.
// - Contains at least min elements.
//
// Null (unconfigured) and unknown (known after apply) values are skipped.
func SizeAtLeast(min int) tfsdk.AttributeValidator {
return sizeAtLeastValidator{
min: min,
Expand Down
7 changes: 7 additions & 0 deletions setvalidator/size_at_most.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func (v sizeAtMostValidator) Validate(ctx context.Context, req tfsdk.ValidateAtt
}
}

// SizeAtMost returns an AttributeValidator which ensures that any configured
// attribute value:
//
// - Is a Set.
// - Contains at most max elements.
//
// Null (unconfigured) and unknown (known after apply) values are skipped.
func SizeAtMost(max int) tfsdk.AttributeValidator {
return sizeAtMostValidator{
max: max,
Expand Down
7 changes: 7 additions & 0 deletions setvalidator/size_between.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func (v sizeBetweenValidator) Validate(ctx context.Context, req tfsdk.ValidateAt
}
}

// SizeBetween returns an AttributeValidator which ensures that any configured
// attribute value:
//
// - Is a Set.
// - Contains at least min elements and at most max elements.
//
// Null (unconfigured) and unknown (known after apply) values are skipped.
func SizeBetween(min, max int) tfsdk.AttributeValidator {
return sizeBetweenValidator{
min: min,
Expand Down

0 comments on commit d6a993c

Please sign in to comment.