Skip to content

Commit 92f4a78

Browse files
committed
Use 'int64' in Int validators.
1 parent 8cf6871 commit 92f4a78

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

internal/validate/int.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type intBetweenValidator struct {
1616
tfsdk.AttributeValidator
1717

18-
min, max int
18+
min, max int64
1919
}
2020

2121
// Description describes the validation in plain text formatting.
@@ -35,7 +35,7 @@ func (validator intBetweenValidator) Validate(ctx context.Context, request tfsdk
3535
return
3636
}
3737

38-
if i < int64(validator.min) || i > int64(validator.max) {
38+
if i < validator.min || i > validator.max {
3939
response.Diagnostics.Append(ccdiag.NewInvalidValueAttributeError(
4040
request.AttributePath,
4141
fmt.Sprintf("expected value to be in the range [%d, %d], got %d", validator.min, validator.max, i),
@@ -46,7 +46,7 @@ func (validator intBetweenValidator) Validate(ctx context.Context, request tfsdk
4646
}
4747

4848
// IntBetween returns a new integer value between validator.
49-
func IntBetween(min, max int) tfsdk.AttributeValidator {
49+
func IntBetween(min, max int64) tfsdk.AttributeValidator {
5050
if min > max {
5151
return nil
5252
}
@@ -61,7 +61,7 @@ func IntBetween(min, max int) tfsdk.AttributeValidator {
6161
type intAtLeastValidator struct {
6262
tfsdk.AttributeValidator
6363

64-
min int
64+
min int64
6565
}
6666

6767
// Description describes the validation in plain text formatting.
@@ -81,7 +81,7 @@ func (validator intAtLeastValidator) Validate(ctx context.Context, request tfsdk
8181
return
8282
}
8383

84-
if i < int64(validator.min) {
84+
if i < validator.min {
8585
response.Diagnostics.Append(ccdiag.NewInvalidValueAttributeError(
8686
request.AttributePath,
8787
fmt.Sprintf("expected value to be at least %d, got %d", validator.min, i),
@@ -92,7 +92,7 @@ func (validator intAtLeastValidator) Validate(ctx context.Context, request tfsdk
9292
}
9393

9494
// IntAtLeast returns a new integer value at least validator.
95-
func IntAtLeast(min int) tfsdk.AttributeValidator {
95+
func IntAtLeast(min int64) tfsdk.AttributeValidator {
9696
return intAtLeastValidator{
9797
min: min,
9898
}
@@ -102,7 +102,7 @@ func IntAtLeast(min int) tfsdk.AttributeValidator {
102102
type intAtMostValidator struct {
103103
tfsdk.AttributeValidator
104104

105-
max int
105+
max int64
106106
}
107107

108108
// Description describes the validation in plain text formatting.
@@ -122,7 +122,7 @@ func (validator intAtMostValidator) Validate(ctx context.Context, request tfsdk.
122122
return
123123
}
124124

125-
if i > int64(validator.max) {
125+
if i > validator.max {
126126
response.Diagnostics.Append(ccdiag.NewInvalidValueAttributeError(
127127
request.AttributePath,
128128
fmt.Sprintf("expected value to be at most %d, got %d", validator.max, i),
@@ -133,7 +133,7 @@ func (validator intAtMostValidator) Validate(ctx context.Context, request tfsdk.
133133
}
134134

135135
// IntAtMost returns a new integer value at most validator.
136-
func IntAtMost(max int) tfsdk.AttributeValidator {
136+
func IntAtMost(max int64) tfsdk.AttributeValidator {
137137
return intAtMostValidator{
138138
max: max,
139139
}

internal/validate/int_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func TestIntBetweenValidator(t *testing.T) {
1717
type testCase struct {
1818
val tftypes.Value
1919
f func(context.Context, tftypes.Value) (attr.Value, error)
20-
min int
21-
max int
20+
min int64
21+
max int64
2222
expectError bool
2323
}
2424
tests := map[string]testCase{
@@ -146,7 +146,7 @@ func TestIntAtLeastValidator(t *testing.T) {
146146
type testCase struct {
147147
val tftypes.Value
148148
f func(context.Context, tftypes.Value) (attr.Value, error)
149-
min int
149+
min int64
150150
expectError bool
151151
}
152152
tests := map[string]testCase{
@@ -233,7 +233,7 @@ func TestIntAtMostValidator(t *testing.T) {
233233
type testCase struct {
234234
val tftypes.Value
235235
f func(context.Context, tftypes.Value) (attr.Value, error)
236-
max int
236+
max int64
237237
expectError bool
238238
}
239239
tests := map[string]testCase{

0 commit comments

Comments
 (0)