csvparam

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package csvparam parses comma-separated flag and query parameter values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(raw string) []string

Parse splits raw on commas, trims whitespace, removes empty tokens, deduplicates, and returns tokens in sorted order. Blank input returns nil.

func ParseAllowed

func ParseAllowed(raw string, allowed []string, param string) ([]string, error)

ParseAllowed parses raw using Parse and validates every token against allowed. All unknown tokens are collected before returning the error so callers receive the full set of violations in a single pass.

Types

type UnknownTokenError

type UnknownTokenError struct {
	Param   string
	Allowed []string
	// Tokens holds the unknown input values. They are excluded from the Error()
	// message — consume via structured slog fields, never inline into responses.
	Tokens []string
}

UnknownTokenError reports that one or more CSV tokens were not in the allowed set. The raw tokens are intentionally omitted from the Error() message so public validation errors do not echo user-supplied input (XSS / log injection prevention). Use the Tokens field for structured logging only.

func (UnknownTokenError) Error

func (e UnknownTokenError) Error() string

Jump to

Keyboard shortcuts

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