validate

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package validate holds shared input checks for agent-supplied identifiers.

Index

Constants

View Source
const MaxNameLength = 50

MaxNameLength is the longest accepted name, in characters.

View Source
const MaxPathSegmentLength = 200

MaxPathSegmentLength bounds one path or object-key segment.

Variables

This section is empty.

Functions

func Name

func Name(field, value string) (string, error)

Name trims value and rejects it if empty, longer than MaxNameLength, or containing anything outside [a-zA-Z0-9_-]. It returns the trimmed value.

func PathSegment

func PathSegment(field, value string) (string, error)

PathSegment rejects value if it could escape or corrupt the location it is interpolated into: empty, "." or "..", a path separator, a control character, or a leading dash that would read as a flag. It returns the trimmed value.

Distinct from Name deliberately. Name encodes the agent naming rules, which are stricter than safety requires and would reject a legitimate platform-generated identifier containing a dot or longer than 50 characters.

func SanitizeName

func SanitizeName(value string) string

SanitizeName coerces value into a valid Name: first dot-separated label, unsupported runs collapsed to "-", dashes trimmed, truncated to MaxNameLength. Returns "" when nothing usable remains.

Types

This section is empty.

Jump to

Keyboard shortcuts

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