validate

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 5 Imported by: 0

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

View Source
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

func Name(name string) error

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

func Path(path string) error

Path rejects file paths that could escape a base directory. It checks for ".." components, absolute paths, and null bytes.

func PathWithinDir

func PathWithinDir(relPath, baseDir string) error

PathWithinDir validates a path and then verifies the resolved absolute path stays within the given base directory.

func Title

func Title(title string) error

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.

Jump to

Keyboard shortcuts

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