Movatterモバイル変換


[0]ホーム

URL:


validator

package
v1.17.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:MPL-2.0Imports:5Imported by:690

Details

Repository

github.com/hashicorp/terraform-plugin-framework

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

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.

typeDynamicadded 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.

typeDynamicRequestadded 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.

typeDynamicResponseadded 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.

typeFloat32added 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.

typeFloat32Requestadded 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.

typeFloat32Responseadded 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.

typeInt32added 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.

typeInt32Requestadded 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.

typeInt32Responseadded 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.

typeValidateSchemaClientCapabilitiesadded 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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp