@@ -73,7 +73,7 @@ func TestParameter(t *testing.T) {
73
73
}
74
74
},
75
75
}, {
76
- Name : "ValidationWithOptions " ,
76
+ Name : "RegexValidationWithOptions " ,
77
77
Config : `
78
78
data "coder_parameter" "region" {
79
79
name = "Region"
@@ -88,7 +88,23 @@ func TestParameter(t *testing.T) {
88
88
}
89
89
}
90
90
` ,
91
- ExpectError : regexp .MustCompile ("conflicts with option" ),
91
+ ExpectError : regexp .MustCompile ("a regex cannot be specified for a number type" ),
92
+ }, {
93
+ Name : "MonotonicValidationWithNonNumberType" ,
94
+ Config : `
95
+ data "coder_parameter" "region" {
96
+ name = "Region"
97
+ type = "string"
98
+ option {
99
+ name = "1"
100
+ value = "1"
101
+ }
102
+ validation {
103
+ monotonic = "increasing"
104
+ }
105
+ }
106
+ ` ,
107
+ ExpectError : regexp .MustCompile ("monotonic validation can only be specified for number types, not string types" ),
92
108
}, {
93
109
Name : "ValidationRegexMissingError" ,
94
110
Config : `
@@ -424,6 +440,54 @@ data "coder_parameter" "region" {
424
440
require .Equal (t , expected , state .Primary .Attributes [key ])
425
441
}
426
442
},
443
+ }, {
444
+ Name : "NumberValidation_MonotonicWithOptions" ,
445
+ Config : `
446
+ data "coder_parameter" "region" {
447
+ name = "Region"
448
+ type = "number"
449
+ description = <<-EOF
450
+ Always pick a larger region.
451
+ EOF
452
+ default = 1
453
+
454
+ option {
455
+ name = "Small"
456
+ value = 1
457
+ }
458
+
459
+ option {
460
+ name = "Medium"
461
+ value = 2
462
+ }
463
+
464
+ option {
465
+ name = "Large"
466
+ value = 3
467
+ }
468
+
469
+ validation {
470
+ monotonic = "increasing"
471
+ }
472
+ }
473
+ ` ,
474
+ Check : func (state * terraform.ResourceState ) {
475
+ for key , expected := range map [string ]any {
476
+ "name" : "Region" ,
477
+ "type" : "number" ,
478
+ "validation.#" : "1" ,
479
+ "option.0.name" : "Small" ,
480
+ "option.0.value" : "1" ,
481
+ "option.1.name" : "Medium" ,
482
+ "option.1.value" : "2" ,
483
+ "option.2.name" : "Large" ,
484
+ "option.2.value" : "3" ,
485
+ "default" : "1" ,
486
+ "validation.0.monotonic" : "increasing" ,
487
+ } {
488
+ require .Equal (t , expected , state .Primary .Attributes [key ])
489
+ }
490
+ },
427
491
}, {
428
492
Name : "NumberValidation_Min" ,
429
493
Config : `
0 commit comments