-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathnone_of.go
More file actions
28 lines (24 loc) · 1.05 KB
/
none_of.go
File metadata and controls
28 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package stringvalidator
import (
"github.com/hashicorp/terraform-plugin-framework-validators/internal/primitivevalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// NoneOf checks that the string held in the attribute
// is none of the given `unacceptableStrings`.
func NoneOf(unacceptableStrings ...string) tfsdk.AttributeValidator {
unacceptableStringValues := make([]attr.Value, 0, len(unacceptableStrings))
for _, s := range unacceptableStrings {
unacceptableStringValues = append(unacceptableStringValues, types.String{Value: s})
}
return primitivevalidator.NoneOf(unacceptableStringValues...)
}
// NoneOfCaseInsensitive checks that the string held in the attribute
// is none of the given `unacceptableStrings`, irrespective of case sensitivity.
func NoneOfCaseInsensitive(unacceptableStrings ...string) tfsdk.AttributeValidator {
return &acceptableStringsCaseInsensitiveAttributeValidator{
unacceptableStrings,
false,
}
}