validator
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package validator contains common schema validator interfaces andimplementations. These validators are used by concept specific packagessuch as datasource/schema, provider/schema, and resource/schema.
Each attr.Type has a corresponding {TYPE}Validator interface whichimplements concretely typed Validate{TYPE} methods, such asStringValidator and ValidateString. Custom attr.Type can also considerimplementing native type validation via the attr/xattr.TypeWithValidateinterface instead of schema validators.
The framework has to choose between validator developers handling a concreteframework value type, such as types.Bool, or the framework interface forcustom value basetypes. such as basetypes.BoolValuable.
In the framework type model, the developer can immediately use the value.If the value was associated with a custom type and using the custom valuetype is desired, the developer must use the type's ValueFrom{TYPE} method.
In the custom type model, the developer must always convert to a concreatetype before using the value unless checking for null or unknown. Since anycustom type may be passed due to the schema, it is possible, if not likely,that unknown concrete types will be passed to the validator.
The framework chooses to pass the framework value type. This prevents thepotential for unexpected runtime panics and simplifies development foreasier use cases where the framework type is sufficient. More advanceddevelopers can choose to implement native type validation for customtypes or call the type's ValueFrom{TYPE} method to get the desireddesired custom type in a validator.
Validators that are not type dependent need to implement all interfaces,but can use shared logic to reduce implementation code.
Index¶
- type Bool
- type BoolRequest
- type BoolResponse
- type Describer
- type Dynamic
- type DynamicRequest
- type DynamicResponse
- type Float32
- type Float32Request
- type Float32Response
- type Float64
- type Float64Request
- type Float64Response
- type Int32
- type Int32Request
- type Int32Response
- type Int64
- type Int64Request
- type Int64Response
- type List
- type ListRequest
- type ListResponse
- type Map
- type MapRequest
- type MapResponse
- type Number
- type NumberRequest
- type NumberResponse
- type Object
- type ObjectRequest
- type ObjectResponse
- type Set
- type SetRequest
- type SetResponse
- type String
- type StringRequest
- type StringResponse
- type ValidateSchemaClientCapabilities
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeBool¶
type Bool interface {Describer// ValidateBool should perform the validation.ValidateBool(context.Context,BoolRequest, *BoolResponse)}Bool is a schema validator for types.Bool attributes.
typeBoolRequest¶
type BoolRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Bool// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}BoolRequest is a request for types.Bool schema validation.
typeBoolResponse¶
type BoolResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}BoolResponse is a response to a BoolRequest.
typeDescriber¶
type Describer interface {// Description should describe the validation in plain text formatting.// This information is used by provider logging and provider tooling such// as documentation generation.//// The description should:// - Begin with a lowercase or other character suitable for the middle of// a sentence.// - End without punctuation.// - Use actionable language, such as "must" or "cannot".// - Avoid newlines. Prefer separate validators instead.//// For example, "size must be less than 50 elements".Description(context.Context)string// MarkdownDescription should describe the validation in Markdown// formatting. This information is used by provider logging and provider// tooling such as documentation generation.//// The description should:// - Begin with a lowercase or other character suitable for the middle of// a sentence.// - End without punctuation.// - Use actionable language, such as "must" or "cannot".// - Avoid newlines. Prefer separate validators instead.//// For example, "value must be `one` or `two`".MarkdownDescription(context.Context)string}Describer is the common documentation interface for extensible schemavalidation functionality.
typeDynamic¶added inv1.7.0
type Dynamic interface {Describer// ValidateDynamic should perform the validation.ValidateDynamic(context.Context,DynamicRequest, *DynamicResponse)}Dynamic is a schema validator for types.Dynamic attributes.
typeDynamicRequest¶added inv1.7.0
type DynamicRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Dynamic// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}DynamicRequest is a request for types.Dynamic schema validation.
typeDynamicResponse¶added inv1.7.0
type DynamicResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}DynamicResponse is a response to a DynamicRequest.
typeFloat32¶added inv1.10.0
type Float32 interface {Describer// ValidateFloat32 should perform the validation.ValidateFloat32(context.Context,Float32Request, *Float32Response)}Float32 is a schema validator for types.Float32 attributes.
typeFloat32Request¶added inv1.10.0
type Float32Request struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Float32// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}Float32Request is a request for types.Float32 schema validation.
typeFloat32Response¶added inv1.10.0
type Float32Response struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}Float32Response is a response to a Float32Request.
typeFloat64¶
type Float64 interface {Describer// ValidateFloat64 should perform the validation.ValidateFloat64(context.Context,Float64Request, *Float64Response)}Float64 is a schema validator for types.Float64 attributes.
typeFloat64Request¶
type Float64Request struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Float64// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}Float64Request is a request for types.Float64 schema validation.
typeFloat64Response¶
type Float64Response struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}Float64Response is a response to a Float64Request.
typeInt32¶added inv1.10.0
type Int32 interface {Describer// ValidateInt32 should perform the validation.ValidateInt32(context.Context,Int32Request, *Int32Response)}Int32 is a schema validator for types.Int32 attributes.
typeInt32Request¶added inv1.10.0
type Int32Request struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Int32// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}Int32Request is a request for types.Int32 schema validation.
typeInt32Response¶added inv1.10.0
type Int32Response struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}Int32Response is a response to a Int32Request.
typeInt64¶
type Int64 interface {Describer// ValidateInt64 should perform the validation.ValidateInt64(context.Context,Int64Request, *Int64Response)}Int64 is a schema validator for types.Int64 attributes.
typeInt64Request¶
type Int64Request struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Int64// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}Int64Request is a request for types.Int64 schema validation.
typeInt64Response¶
type Int64Response struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}Int64Response is a response to a Int64Request.
typeList¶
type List interface {Describer// ValidateList should perform the validation.ValidateList(context.Context,ListRequest, *ListResponse)}List is a schema validator for types.List attributes.
typeListRequest¶
type ListRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.List// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}ListRequest is a request for types.List schema validation.
typeListResponse¶
type ListResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}ListResponse is a response to a ListRequest.
typeMap¶
type Map interface {Describer// ValidateMap should perform the validation.ValidateMap(context.Context,MapRequest, *MapResponse)}Map is a schema validator for types.Map attributes.
typeMapRequest¶
type MapRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Map// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}MapRequest is a request for types.Map schema validation.
typeMapResponse¶
type MapResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}MapResponse is a response to a MapRequest.
typeNumber¶
type Number interface {Describer// ValidateNumber should perform the validation.ValidateNumber(context.Context,NumberRequest, *NumberResponse)}Number is a schema validator for types.Number attributes.
typeNumberRequest¶
type NumberRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Number// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}NumberRequest is a request for types.Number schema validation.
typeNumberResponse¶
type NumberResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}NumberResponse is a response to a NumberRequest.
typeObject¶
type Object interface {Describer// ValidateObject should perform the validation.ValidateObject(context.Context,ObjectRequest, *ObjectResponse)}Object is a schema validator for types.Object attributes.
typeObjectRequest¶
type ObjectRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Object// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}ObjectRequest is a request for types.Object schema validation.
typeObjectResponse¶
type ObjectResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}ObjectResponse is a response to a ObjectRequest.
typeSet¶
type Set interface {Describer// ValidateSet should perform the validation.ValidateSet(context.Context,SetRequest, *SetResponse)}Set is a schema validator for types.Set attributes.
typeSetRequest¶
type SetRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.Set// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}SetRequest is a request for types.Set schema validation.
typeSetResponse¶
type SetResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}SetResponse is a response to a SetRequest.
typeString¶
type String interface {Describer// ValidateString should perform the validation.ValidateString(context.Context,StringRequest, *StringResponse)}String is a schema validator for types.String attributes.
typeStringRequest¶
type StringRequest struct {// Path contains the path of the attribute for validation. Use this path// for any response diagnostics.Pathpath.Path// PathExpression contains the expression matching the exact path// of the attribute for validation.PathExpressionpath.Expression// Config contains the entire configuration of the data source, provider, or resource.Configtfsdk.Config// ConfigValue contains the value of the attribute for validation from the configuration.ConfigValuetypes.String// ClientCapabilities defines optionally supported protocol features for// schema validation RPCs, such as forward-compatible Terraform// behavior changes.ClientCapabilitiesValidateSchemaClientCapabilities}StringRequest is a request for types.String schema validation.
typeStringResponse¶
type StringResponse struct {// Diagnostics report errors or warnings related to validating the data source, provider, or resource// configuration. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}StringResponse is a response to a StringRequest.
typeValidateSchemaClientCapabilities¶added inv1.14.0
type ValidateSchemaClientCapabilities struct {// WriteOnlyAttributesAllowed indicates that the Terraform client// initiating the request supports write-only attributes for managed// resources.//// This client capability is only populated during managed resource schema// validation.WriteOnlyAttributesAllowedbool}ValidateSchemaClientCapabilities allows Terraform to publish informationregarding optionally supported protocol features for the schema validationRPCs, such as forward-compatible Terraform behavior changes.