Documentation
¶
Overview ¶
Package validate provides input validation functions for the ytr CLI.
Index ¶
- func ParseJSONInput(value string) ([]byte, error)
- func ParseJSONInputFrom(value string, stdin io.Reader) ([]byte, error)
- func ParsePageCursor(cursor string) (int, error)
- func ValidateIssueKey(key string) error
- func ValidateNoControlChars(fieldName, value string) error
- func ValidateNumericID(arg, label string) (int, error)
- func ValidateStringID(arg, label string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJSONInput ¶
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 ¶
ParseJSONInputFrom reads JSON data from the given source, using the provided reader for stdin. This variant enables testing without replacing os.Stdin.
func ParsePageCursor ¶
ParsePageCursor parses cursor as a positive 1-based page number. Empty cursor means the first page.
func ValidateIssueKey ¶
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 ¶
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 ¶
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 ¶
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.