-
Notifications
You must be signed in to change notification settings - Fork 91
/
string.go
43 lines (34 loc) · 1.33 KB
/
string.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package validator
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// String is a schema validator for types.String attributes.
type String interface {
Describer
// ValidateString should perform the validation.
ValidateString(context.Context, StringRequest, *StringResponse)
}
// StringRequest is a request for types.String schema validation.
type StringRequest struct {
// Path contains the path of the attribute for validation. Use this path
// for any response diagnostics.
Path path.Path
// PathExpression contains the expression matching the exact path
// of the attribute for validation.
PathExpression path.Expression
// Config contains the entire configuration of the data source, provider, or resource.
Config tfsdk.Config
// ConfigValue contains the value of the attribute for validation from the configuration.
ConfigValue types.String
}
// StringResponse is a response to a StringRequest.
type StringResponse struct {
// Diagnostics report errors or warnings related to validating the data
// source configuration. An empty slice indicates success, with no warnings
// or errors generated.
Diagnostics diag.Diagnostics
}