Documentation
¶
Overview ¶
Package validate provides shared input-validation helpers enforcing the filesystem-safety invariants in AGENTS.md:
- Reject file paths containing "..", absolute paths, or null bytes.
- Sanitize names (memory names, project slugs, note slugs) for filesystem safety.
Ported from Seam v1 (internal/validate) with one deliberate change: Title no longer rejects "..". Titles are slugified before any filesystem use, and the old check bounced legitimate titles such as "summary 2026-07-05..08" (a 37% error rate on create in v1). Name and Path keep the ".." guard because their inputs feed filesystem operations directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPathTraversal is returned when a path contains "..", is absolute, or // contains null bytes. ErrPathTraversal = errors.New("path contains traversal sequence, absolute path, or null bytes") // ErrUnsafeName is returned when a name contains filesystem-unsafe // characters or patterns. ErrUnsafeName = errors.New("name contains unsafe characters") )
Functions ¶
func Name ¶
Name rejects names used to build filenames (memory names, project/note slugs) that contain filesystem-unsafe characters: null bytes, forward/back slashes, or ".." sequences. It also enforces a maximum length of 255 characters.
func Path ¶
Path rejects file paths that could escape a base directory. It checks for ".." components, absolute paths, and null bytes.
func PathWithinDir ¶
PathWithinDir validates a path and then verifies the resolved absolute path stays within the given base directory.
func Title ¶
Title validates human-facing titles and descriptions. It is more permissive than Name: it allows "/" (e.g. "TCP/IP", "A/B testing") and ".." (e.g. date ranges like "2026-07-05..08") because titles are slugified before any filesystem use. It rejects empty strings, null bytes, backslashes, and lengths over 255.
Types ¶
This section is empty.