@@ -24,9 +24,14 @@ import (
24
24
type ValidationMode string
25
25
26
26
const (
27
- // ValidationModeDefault is used for creating a workspace. It validates the
28
- // final value used for a parameter.
29
- ValidationModeDefault ValidationMode = ""
27
+ // ValidationModeDefault is used for creating a workspace. It validates the final
28
+ // value used for a parameter. Some allowances for invalid options are tolerated,
29
+ // as unused options do not affect the final parameter value. The default value
30
+ // is also ignored, assuming a value is provided.
31
+ ValidationModeDefault ValidationMode = ""
32
+ // ValidationModeTemplateImport tolerates empty values, as the value might not be
33
+ // available at import. It does not tolerate an invalid default or invalid option
34
+ // values.
30
35
ValidationModeTemplateImport ValidationMode = "template-import"
31
36
)
32
37
@@ -413,6 +418,14 @@ func (v *Parameter) Valid(input *string, mode ValidationMode) (string, diag.Diag
413
418
value = v .Default
414
419
}
415
420
421
+ // TODO: When empty values want to be rejected, uncomment this.
422
+ // coder/coder should update to use template import mode first,
423
+ // before this is uncommented.
424
+ //if value == nil && mode == ValidationModeDefault {
425
+ // var empty string
426
+ // value = &empty
427
+ //}
428
+
416
429
// optionType might differ from parameter.Type. This is ok, and parameter.Type
417
430
// should be used for the value type, and optionType for options.
418
431
optionType , v .FormType , err = ValidateFormType (v .Type , len (v .Option ), v .FormType )
0 commit comments