validators

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FoundIn added in v0.4.0

func FoundIn(msg string, paths ...path.Expression) validator.String

FoundIn creates a new validator that checks if a string value exists in any of the specified path expressions.

Parameters:

  • msg: The error message to display if the value is not found
  • paths: One or more path expressions where the value should be found

func GFFieldBool added in v0.3.0

func GFFieldBool(val GameFabricValidator, pathExpr string) validator.Bool

GFFieldBool creates a GameFabric attribute validator for boolean attributes.

func GFFieldDynamic added in v0.3.0

func GFFieldDynamic(val GameFabricValidator, pathExpr string) validator.Dynamic

GFFieldDynamic creates a GameFabric attribute validator for dynamic attributes.

func GFFieldFloat32 added in v0.3.0

func GFFieldFloat32(val GameFabricValidator, pathExpr string) validator.Float32

GFFieldFloat32 creates a GameFabric attribute validator for float32 attributes.

func GFFieldFloat64 added in v0.3.0

func GFFieldFloat64(val GameFabricValidator, pathExpr string) validator.Float64

GFFieldFloat64 creates a GameFabric attribute validator for float64 attributes.

func GFFieldInt32 added in v0.3.0

func GFFieldInt32(val GameFabricValidator, pathExpr string) validator.Int32

GFFieldInt32 creates a GameFabric attribute validator for int32 attributes.

func GFFieldInt64 added in v0.3.0

func GFFieldInt64(val GameFabricValidator, pathExpr string) validator.Int64

GFFieldInt64 creates a GameFabric attribute validator for int64 attributes.

func GFFieldList added in v0.3.0

func GFFieldList(val GameFabricValidator, pathExpr string) validator.List

GFFieldList creates a GameFabric attribute validator for list attributes.

func GFFieldMap added in v0.3.0

func GFFieldMap(val GameFabricValidator, pathExpr string) validator.Map

GFFieldMap creates a GameFabric attribute validator for map attributes.

func GFFieldNumber added in v0.3.0

func GFFieldNumber(val GameFabricValidator, pathExpr string) validator.Number

GFFieldNumber creates a GameFabric attribute validator for number attributes.

func GFFieldObject added in v0.3.0

func GFFieldObject(val GameFabricValidator, pathExpr string) validator.Object

GFFieldObject creates a GameFabric attribute validator for object attributes.

func GFFieldSet added in v0.3.0

func GFFieldSet(val GameFabricValidator, pathExpr string) validator.Set

GFFieldSet creates a GameFabric attribute validator for set attributes.

func GFFieldString added in v0.3.0

func GFFieldString(val GameFabricValidator, pathExpr string) validator.String

GFFieldString creates a GameFabric attribute validator for string attributes.

func GreaterOrEqualTo added in v1.2.0

func GreaterOrEqualTo(path ...path.Expression) validator.Int32

func LessOrEqualTo added in v1.2.0

func LessOrEqualTo(path ...path.Expression) validator.Int32

Types

type AnnotationsValidator

type AnnotationsValidator struct{}

AnnotationsValidator is a custom validator that checks if a map's keys and values are valid.

func (AnnotationsValidator) Description

func (n AnnotationsValidator) Description(context.Context) string

Description provides a description of the validator.

func (AnnotationsValidator) MarkdownDescription

func (n AnnotationsValidator) MarkdownDescription(context.Context) string

MarkdownDescription provides a markdown description of the validator.

func (AnnotationsValidator) ValidateMap

ValidateMap checks that the provided map's keys and values are valid.

type CIDRValidator added in v0.2.0

type CIDRValidator struct{}

CIDRValidator validates that a string is a valid CIDR.

func (*CIDRValidator) Description added in v0.2.0

func (v *CIDRValidator) Description(_ context.Context) string

Description provides a description of the validator.

func (*CIDRValidator) MarkdownDescription added in v0.2.0

func (v *CIDRValidator) MarkdownDescription(ctx context.Context) string

MarkdownDescription provides a markdown description of the validator.

func (*CIDRValidator) ValidateList added in v0.2.0

func (v *CIDRValidator) ValidateList(_ context.Context, req validator.ListRequest, resp *validator.ListResponse)

ValidateList checks that each string in the list is a valid CIDR.

type EnvironmentValidator

type EnvironmentValidator struct{}

EnvironmentValidator is a custom validator that checks if a string is a valid environment name.

func (EnvironmentValidator) Description

func (n EnvironmentValidator) Description(context.Context) string

Description provides a description of the validator.

func (EnvironmentValidator) MarkdownDescription

func (n EnvironmentValidator) MarkdownDescription(context.Context) string

MarkdownDescription provides a markdown description of the validator.

func (EnvironmentValidator) ValidateString

ValidateString checks that the provided string is a valid name.

type GameFabricValidator added in v0.3.0

type GameFabricValidator interface {
	Validate(ctx context.Context, req GameFabricValidatorRequest) diag.Diagnostics
}

GameFabricValidator defines the interface for validating GameFabric configuration values.

func NewGameFabricValidator added in v0.3.0

func NewGameFabricValidator[T runtime.Object, M Model[T]](fn func() StoreValidator) GameFabricValidator

NewGameFabricValidator creates a new gamefabricStoreValidator that wraps the given StoreValidator.

type GameFabricValidatorRequest added in v0.3.0

type GameFabricValidatorRequest struct {
	Config      tfsdk.Config
	ConfigValue attr.Value
	Path        path.Path
	PathExpr    string
}

GameFabricValidatorRequest represents a request to validate a GameFabric configuration value.

type LabelsValidator

type LabelsValidator struct{}

LabelsValidator is a custom validator that checks if a map's keys and values are valid.

func (LabelsValidator) Description

func (n LabelsValidator) Description(context.Context) string

Description provides a description of the validator.

func (LabelsValidator) MarkdownDescription

func (n LabelsValidator) MarkdownDescription(context.Context) string

MarkdownDescription provides a markdown description of the validator.

func (LabelsValidator) ValidateMap

ValidateMap checks that the provided map's keys and values are valid.

type MinReplicasValidator added in v1.2.0

type MinReplicasValidator struct{}

MinReplicasValidator validates the relationship between `min_replicas`, `buffer_size` and `dynamic_buffer` attributes within a replicas list entry.

Rules:

  • A value of 0 is always allowed and instructs the API to use the buffer value as the effective minimum.
  • When the value is non-zero it must be >= buffer_size.
  • When dynamic_buffer is configured the validator emits warnings to guide the user toward the most useful configuration:
  • min_replicas == buffer_size: suggest setting min_replicas to 0 to give the dynamic buffer full control.
  • min_replicas > buffer_size: explain that dynamic buffer cannot grow the buffer beyond min_replicas.
  • min_replicas == 0: no warning is emitted.

func (MinReplicasValidator) Description added in v1.2.0

func (v MinReplicasValidator) Description(_ context.Context) string

Description describes the validation in plain text formatting.

func (MinReplicasValidator) MarkdownDescription added in v1.2.0

func (v MinReplicasValidator) MarkdownDescription(ctx context.Context) string

MarkdownDescription describes the validation in Markdown formatting.

func (MinReplicasValidator) ValidateInt32 added in v1.2.0

func (v MinReplicasValidator) ValidateInt32(ctx context.Context, request validator.Int32Request, response *validator.Int32Response)

ValidateInt32 performs the validation.

type Model added in v0.3.0

type Model[T runtime.Object] interface {
	ToObject() T
}

Model represents a model that can be converted to its underlying runtime.Object.

type NameValidator

type NameValidator struct{}

NameValidator is a custom validator that checks if a string is a valid name.

func (NameValidator) Description

func (n NameValidator) Description(context.Context) string

Description provides a description of the validator.

func (NameValidator) MarkdownDescription

func (n NameValidator) MarkdownDescription(context.Context) string

MarkdownDescription provides a markdown description of the validator.

func (NameValidator) ValidateString

ValidateString checks that the provided string is a valid name.

type QuantityValidator added in v0.3.0

type QuantityValidator struct{}

QuantityValidator validates that a string is a valid resource quantity.

func (QuantityValidator) Description added in v0.3.0

func (v QuantityValidator) Description(_ context.Context) string

Description provides a description of the validator.

func (QuantityValidator) MarkdownDescription added in v0.3.0

func (v QuantityValidator) MarkdownDescription(ctx context.Context) string

MarkdownDescription provides a markdown formatted description of the validator.

func (QuantityValidator) ValidateString added in v0.3.0

ValidateString checks that the string is a valid resource quantity.

type StoreValidator added in v0.3.0

type StoreValidator interface {
	Validate(obj runtime.Object) validation.Errors
}

StoreValidator represents a GameFabric store that can validate runtime.Objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL