@@ -10,57 +10,57 @@ import (
1010// IntBetween returns a SchemaValidateFunc which tests if the provided value
1111// is of type int and is between min and max (inclusive)
1212func IntBetween (min , max int ) schema.SchemaValidateFunc {
13- return func (i interface {}, k string ) (s []string , es []error ) {
13+ return func (i interface {}, k string ) (warnings []string , errors []error ) {
1414 v , ok := i .(int )
1515 if ! ok {
16- es = append (es , fmt .Errorf ("expected type of %s to be int " , k ))
17- return
16+ errors = append (errors , fmt .Errorf ("expected type of %s to be integer " , k ))
17+ return warnings , errors
1818 }
1919
2020 if v < min || v > max {
21- es = append (es , fmt .Errorf ("expected %s to be in the range (%d - %d), got %d" , k , min , max , v ))
22- return
21+ errors = append (errors , fmt .Errorf ("expected %s to be in the range (%d - %d), got %d" , k , min , max , v ))
22+ return warnings , errors
2323 }
2424
25- return
25+ return warnings , errors
2626 }
2727}
2828
2929// IntAtLeast returns a SchemaValidateFunc which tests if the provided value
3030// is of type int and is at least min (inclusive)
3131func IntAtLeast (min int ) schema.SchemaValidateFunc {
32- return func (i interface {}, k string ) (s []string , es []error ) {
32+ return func (i interface {}, k string ) (warnings []string , errors []error ) {
3333 v , ok := i .(int )
3434 if ! ok {
35- es = append (es , fmt .Errorf ("expected type of %s to be int " , k ))
36- return
35+ errors = append (errors , fmt .Errorf ("expected type of %s to be integer " , k ))
36+ return warnings , errors
3737 }
3838
3939 if v < min {
40- es = append (es , fmt .Errorf ("expected %s to be at least (%d), got %d" , k , min , v ))
41- return
40+ errors = append (errors , fmt .Errorf ("expected %s to be at least (%d), got %d" , k , min , v ))
41+ return warnings , errors
4242 }
4343
44- return
44+ return warnings , errors
4545 }
4646}
4747
4848// IntAtMost returns a SchemaValidateFunc which tests if the provided value
4949// is of type int and is at most max (inclusive)
5050func IntAtMost (max int ) schema.SchemaValidateFunc {
51- return func (i interface {}, k string ) (s []string , es []error ) {
51+ return func (i interface {}, k string ) (warnings []string , errors []error ) {
5252 v , ok := i .(int )
5353 if ! ok {
54- es = append (es , fmt .Errorf ("expected type of %s to be int " , k ))
55- return
54+ errors = append (errors , fmt .Errorf ("expected type of %s to be integer " , k ))
55+ return warnings , errors
5656 }
5757
5858 if v > max {
59- es = append (es , fmt .Errorf ("expected %s to be at most (%d), got %d" , k , max , v ))
60- return
59+ errors = append (errors , fmt .Errorf ("expected %s to be at most (%d), got %d" , k , max , v ))
60+ return warnings , errors
6161 }
6262
63- return
63+ return warnings , errors
6464 }
6565}
6666
@@ -70,13 +70,13 @@ func IntDivisibleBy(divisor int) schema.SchemaValidateFunc {
7070 return func (i interface {}, k string ) (warnings []string , errors []error ) {
7171 v , ok := i .(int )
7272 if ! ok {
73- errors = append (errors , fmt .Errorf ("expected type of %s to be int " , k ))
74- return
73+ errors = append (errors , fmt .Errorf ("expected type of %s to be integer " , k ))
74+ return warnings , errors
7575 }
7676
7777 if math .Mod (float64 (v ), float64 (divisor )) != 0 {
7878 errors = append (errors , fmt .Errorf ("expected %s to be divisible by %d, got: %v" , k , divisor , i ))
79- return
79+ return warnings , errors
8080 }
8181
8282 return warnings , errors
@@ -86,32 +86,32 @@ func IntDivisibleBy(divisor int) schema.SchemaValidateFunc {
8686// IntInSlice returns a SchemaValidateFunc which tests if the provided value
8787// is of type int and matches the value of an element in the valid slice
8888func IntInSlice (valid []int ) schema.SchemaValidateFunc {
89- return func (i interface {}, k string ) (s []string , es []error ) {
89+ return func (i interface {}, k string ) (warnings []string , errors []error ) {
9090 v , ok := i .(int )
9191 if ! ok {
92- es = append (es , fmt .Errorf ("expected type of %s to be an integer" , k ))
93- return
92+ errors = append (errors , fmt .Errorf ("expected type of %s to be integer" , k ))
93+ return warnings , errors
9494 }
9595
9696 for _ , validInt := range valid {
9797 if v == validInt {
98- return
98+ return warnings , errors
9999 }
100100 }
101101
102- es = append (es , fmt .Errorf ("expected %s to be one of %v, got %d" , k , valid , v ))
103- return
102+ errors = append (errors , fmt .Errorf ("expected %s to be one of %v, got %d" , k , valid , v ))
103+ return warnings , errors
104104 }
105105}
106106
107107// IntNotInSlice returns a SchemaValidateFunc which tests if the provided value
108108// is of type int and matches the value of an element in the valid slice
109109func IntNotInSlice (valid []int ) schema.SchemaValidateFunc {
110- return func (i interface {}, k string ) (_ []string , errors []error ) {
110+ return func (i interface {}, k string ) (warnings []string , errors []error ) {
111111 v , ok := i .(int )
112112 if ! ok {
113- errors = append (errors , fmt .Errorf ("expected type of %s to be an integer" , k ))
114- return
113+ errors = append (errors , fmt .Errorf ("expected type of %s to be integer" , k ))
114+ return warnings , errors
115115 }
116116
117117 for _ , validInt := range valid {
@@ -120,6 +120,6 @@ func IntNotInSlice(valid []int) schema.SchemaValidateFunc {
120120 }
121121 }
122122
123- return
123+ return warnings , errors
124124 }
125125}
0 commit comments