string

package
v0.1.924 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blackbox

type Blackbox interface {
	// contains filtered or unexported methods
}

type Client

type Client interface {
	Blackbox
	contract.StringOperator
}

func NewClient

func NewClient() Client

type DefaultTool

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *DefaultTool

func (*DefaultTool) Conform

func (d *DefaultTool) Conform(ctx context.Context, v any) error

Conform modifies fields in a struct or slice of strings to meet normalization rules.

func (*DefaultTool) GenerateUsername added in v0.1.426

func (d *DefaultTool) GenerateUsername(ctx context.Context, opts contract.GenerateUsernameOptions) (string, error)

GenerateUsername creates a username from name fragments, applying profanity filters and rules.

func (*DefaultTool) Normalize

func (d *DefaultTool) Normalize(ctx context.Context, s string, opts contract.NormalizeOptions) (string, error)

Normalize applies configurable transformations to a string such as case folding, trimming, and diacritic removal.

func (*DefaultTool) ParseDynamicType

func (d *DefaultTool) ParseDynamicType(ctx context.Context, s string) (any, error)

ParseDynamicType attempts to convert a string into a strongly typed Go value. It follows a specific order of precedence, attempting to cast the string to one of the following types:

  • ObjectID: Checks if the string is a valid BSON ObjectID.
  • int64: Attempts to parse the string as an integer and casts it to int64. This ensures consistent BSON type matching with MongoDB's native 64-bit integer type.
  • bool: Tries to parse the string as a boolean value ("true", "false").
  • float64: Attempts to parse the string as a floating-point number.
  • time.Time: Tries to parse the string using the RFC3339 time format.

If none of the above conversions succeed, the function falls back to returning the original string.

func (*DefaultTool) ParseQueryString

func (d *DefaultTool) ParseQueryString(ctx context.Context, s string) (map[string][]string, error)

ParseQueryString parses a raw query string into a map of query parameters.

func (*DefaultTool) ReverseString added in v0.1.426

func (d *DefaultTool) ReverseString(ctx context.Context, s string) (string, error)

ReverseString returns the reversed version of a given string.

type Tool

type Tool interface {
	contract.StringOperator
}

Jump to

Keyboard shortcuts

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