validate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package validate provides input validation functions for the ytr CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJSONInput

func ParseJSONInput(value string) ([]byte, error)

ParseJSONInput reads JSON data from one of three sources:

  • "-" reads from os.Stdin.
  • "@path" reads from the file at path.
  • anything else is treated as inline JSON.

func ParseJSONInputFrom

func ParseJSONInputFrom(value string, stdin io.Reader) ([]byte, error)

ParseJSONInputFrom reads JSON data from the given source, using the provided reader for stdin. This variant enables testing without replacing os.Stdin.

func ParsePageCursor

func ParsePageCursor(cursor string) (int, error)

ParsePageCursor parses cursor as a positive 1-based page number. Empty cursor means the first page.

func ValidateIssueKey

func ValidateIssueKey(key string) error

ValidateIssueKey validates that key matches the Yandex Tracker issue key format. Valid keys: PROJ-123, PROJ_V2-42. Invalid: proj-123, PROJ-0, PROJ, empty.

func ValidateNoControlChars

func ValidateNoControlChars(fieldName, value string) error

ValidateNoControlChars checks that value contains no control characters except tab (0x09), newline (0x0A), and carriage return (0x0D). Returns a structured error identifying the offending character and position.

func ValidateNumericID

func ValidateNumericID(arg, label string) (int, error)

ValidateNumericID parses arg as a positive integer. Returns the parsed value and nil on success, or an ExitError with a descriptive message using label (e.g., "comment ID").

func ValidateStringID

func ValidateStringID(arg, label string) (string, error)

ValidateStringID checks that arg is a non-empty string ID. Returns the trimmed value and nil on success, or an ExitError with a descriptive message using label (e.g., "link ID").

Types

This section is empty.

Jump to

Keyboard shortcuts

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