Skip to content

Commit 05e682d

Browse files
committed
add invalid boolean validation field
1 parent 0b94955 commit 05e682d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: provider/parameter.go

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type Validation struct {
3434
Max int
3535
MaxDisabled bool `mapstructure:"max_disabled"`
3636

37+
Invalid bool
3738
Monotonic string
3839

3940
Regex string
@@ -363,6 +364,11 @@ func parameterDataSource() *schema.Resource {
363364
Description: "A regex for the input parameter to match against.",
364365
Optional: true,
365366
},
367+
"invalid": {
368+
Type: schema.TypeBool,
369+
Optional: true,
370+
Description: "If invalid is 'true', the error will be shown.",
371+
},
366372
"error": {
367373
Type: schema.TypeString,
368374
Optional: true,
@@ -452,6 +458,10 @@ func valueIsType(typ, value string) diag.Diagnostics {
452458
}
453459

454460
func (v *Validation) Valid(typ, value string) error {
461+
if v.Invalid {
462+
return v.errorRendered(value)
463+
}
464+
455465
if typ != "number" {
456466
if !v.MinDisabled {
457467
return fmt.Errorf("a min cannot be specified for a %s type", typ)

0 commit comments

Comments
 (0)