validators

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DescriptionValidator

type DescriptionValidator struct{}

DescriptionValidator ensures the string does not have leading/trailing whitespace and does not exceed 250 characters.

func (DescriptionValidator) Description

func (v DescriptionValidator) Description(ctx context.Context) string

Description provides a plain text description of the validator's behavior.

func (DescriptionValidator) MarkdownDescription

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

MarkdownDescription provides a markdown description of the validator's behavior.

func (DescriptionValidator) ValidateString

ValidateString performs the validation logic.

type DisallowListValidator

type DisallowListValidator struct {
	// Forbidden is the list of disallowed string values
	Forbidden []string
}

DisallowListValidator ensures a value is not one of a forbidden set

func (DisallowListValidator) Description

func (v DisallowListValidator) Description(ctx context.Context) string

Description returns a human-friendly description of this validator.

func (DisallowListValidator) MarkdownDescription

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

MarkdownDescription returns the markdown-formatted description.

func (DisallowListValidator) ValidateString

ValidateString checks whether the given value matches any forbidden entry.

type DisallowPrefixValidator

type DisallowPrefixValidator struct {
	// Prefix is the forbidden starting substring
	Prefix string
}

DisallowPrefixValidator holds the prefix that must not be used

func (DisallowPrefixValidator) Description

func (v DisallowPrefixValidator) Description(ctx context.Context) string

Description returns a human-friendly description of this validator.

func (DisallowPrefixValidator) MarkdownDescription

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

MarkdownDescription returns the markdown-formatted description.

func (DisallowPrefixValidator) ValidateString

ValidateString checks whether the given value starts with the forbidden prefix.

type LinkValidator

type LinkValidator struct{}

LinkValidator ensures the string matches the required pattern and length constraints.

func (LinkValidator) Description

func (v LinkValidator) Description(ctx context.Context) string

Description provides a plain text description of the validator's behavior.

func (LinkValidator) MarkdownDescription

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

MarkdownDescription provides a markdown description of the validator's behavior.

func (LinkValidator) ValidateString

func (v LinkValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse)

ValidateString performs the validation logic.

type NameValidator

type NameValidator struct{}

NameValidator ensures the string matches the required pattern and length constraints.

func (NameValidator) Description

func (v NameValidator) Description(ctx context.Context) string

Description provides a plain text description of the validator's behavior.

func (NameValidator) MarkdownDescription

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

MarkdownDescription provides a markdown description of the validator's behavior.

func (NameValidator) ValidateString

func (v NameValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse)

ValidateString performs the validation logic.

type PrefixStringValidator

type PrefixStringValidator struct {
	// Prefix is the expected beginning of the string
	Prefix string

	// Regex is the compiled pattern used to validate the string prefix
	Regex *regexp.Regexp

	// Label is used in error messages to describe what kind of value is expected
	Label string
}

PrefixStringValidator checks if a string starts with a given prefix or matches a regex pattern.

func NewPrefixStringValidator

func NewPrefixStringValidator(prefix, label string) PrefixStringValidator

NewPrefixStringValidator returns a new validator with the given prefix or regex.

func (PrefixStringValidator) Description

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

Description returns a plain text description of the validator's behavior.

func (PrefixStringValidator) MarkdownDescription

func (v PrefixStringValidator) MarkdownDescription(_ context.Context) string

MarkdownDescription returns a markdown description of the validator's behavior.

func (PrefixStringValidator) ValidateString

ValidateString performs validation on the input string.

type TagValidator

type TagValidator struct{}

TagValidator ensures the map of tags does not exceed 50 entries.

func (TagValidator) Description

func (v TagValidator) Description(ctx context.Context) string

Description provides a plain text description of the validator's behavior.

func (TagValidator) MarkdownDescription

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

MarkdownDescription provides a markdown description of the validator's behavior.

func (TagValidator) ValidateMap

func (v TagValidator) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse)

ValidateMap checks if the tag map contains more than 50 entries.

Jump to

Keyboard shortcuts

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