Help us shape the future of Go! Take the 2026 Go Developer Survey

validation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package validation provides input validation utilities for security-critical operations.

This package contains validators for user-provided inputs that are used in database queries, file paths, or subprocess calls. Using these validators prevents injection attacks (SQL/Flux injection, command injection, path traversal).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeTicker

func SanitizeTicker(ticker string) (string, error)

SanitizeTicker normalizes and validates a ticker symbol. Returns the uppercase ticker if valid, or an error if invalid.

Use this when you need both validation and normalization:

safeTicker, err := validation.SanitizeTicker(userInput)
if err != nil {
    return err
}
// safeTicker is uppercase and validated

func ValidateTicker

func ValidateTicker(ticker string) error

ValidateTicker validates a stock ticker symbol to prevent Flux injection.

Valid tickers:

  • 1-10 characters
  • Uppercase letters A-Z
  • Digits 0-9
  • Dots (.) for class shares like BRK.A
  • Hyphens (-) for class shares like BF-B

Returns an error if the ticker is invalid.

Example:

if err := validation.ValidateTicker(ticker); err != nil {
    return nil, fmt.Errorf("invalid ticker: %w", err)
}
// Safe to use in Flux query

func ValidateTickers

func ValidateTickers(tickers []string) error

ValidateTickers validates multiple ticker symbols. Returns an error listing all invalid tickers if any fail validation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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