Documentation
¶
Index ¶
- type Blackbox
- type Client
- type DefaultTool
- func (d *DefaultTool) Conform(ctx context.Context, v any) error
- func (d *DefaultTool) GenerateUsername(ctx context.Context, opts contract.GenerateUsernameOptions) (string, error)
- func (d *DefaultTool) Normalize(ctx context.Context, s string, opts contract.NormalizeOptions) (string, error)
- func (d *DefaultTool) ParseDynamicType(ctx context.Context, s string) (any, error)
- func (d *DefaultTool) ParseQueryString(ctx context.Context, s string) (map[string][]string, error)
- func (d *DefaultTool) ReverseString(ctx context.Context, s string) (string, error)
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Blackbox
contract.StringOperator
}
type DefaultTool ¶
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 ¶
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 ¶
ParseQueryString parses a raw query string into a map of query parameters.
func (*DefaultTool) ReverseString ¶ added in v0.1.426
ReverseString returns the reversed version of a given string.
type Tool ¶
type Tool interface {
contract.StringOperator
}