Skip to content

Commit 79a241d

Browse files
committed
pseudocode: max_ok, min_ok
1 parent 0d0a3c8 commit 79a241d

File tree

2 files changed

+29
-424
lines changed

2 files changed

+29
-424
lines changed

provider/parameter.go

+21-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ type Option struct {
2828
}
2929

3030
type Validation struct {
31-
Min *int
32-
Max *int
31+
Min *int
32+
MinOk bool `mapstructure:"min_ok"`
33+
Max *int
34+
MaxOk bool `mapstructure:"max_ok"`
35+
3336
Monotonic string
3437

3538
Regex string
@@ -288,11 +291,21 @@ func parameterDataSource() *schema.Resource {
288291
Optional: true,
289292
Description: "The minimum of a number parameter.",
290293
},
294+
"min_ok": {
295+
Type: schema.TypeBool,
296+
Computed: true,
297+
Description: "Helper field to check if min is present",
298+
},
291299
"max": {
292300
Type: schema.TypeInt,
293301
Optional: true,
294302
Description: "The maximum of a number parameter.",
295303
},
304+
"max_ok": {
305+
Type: schema.TypeBool,
306+
Computed: true,
307+
Description: "Helper field to check if max is present",
308+
},
296309
"monotonic": {
297310
Type: schema.TypeString,
298311
Optional: true,
@@ -366,9 +379,15 @@ func fixValidationResourceData(rawConfig cty.Value, validation interface{}) (int
366379
// Fix the resource data
367380
if rawValidationRule["min"].IsNull() {
368381
validationRule["min"] = nil
382+
validationRule["min_ok"] = false
383+
} else {
384+
validationRule["min_ok"] = true
369385
}
370386
if rawValidationRule["max"].IsNull() {
371387
validationRule["max"] = nil
388+
validationRule["max_ok"] = false
389+
} else {
390+
validationRule["max_ok"] = true
372391
}
373392
return vArr, nil
374393
}

0 commit comments

Comments
 (0)