validation

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package validation provides input validation utilities for Linear API operations.

This package contains validation functions and constants used throughout the Linear client to ensure data integrity before making API calls.

Validation Constants

Linear API enforces specific limits on field lengths:

validation.MaxTitleLength        // 255 characters
validation.MaxDescriptionLength  // 100,000 characters
validation.MaxNotificationLimit  // 250 notifications per request

String Validation

Validate string lengths against Linear's limits:

err := validation.ValidateStringLength(title, "title", validation.MaxTitleLength)
if err != nil {
    // Title exceeds 255 characters
}

Numeric Validation

Validate numeric ranges with helpful error messages:

err := validation.ValidatePositiveIntWithRange(priority, "priority", 0, 4)
if err != nil {
    // Priority must be between 0 and 4
}

Special Format Validation

Validate emoji and metadata key formats:

if !validation.IsValidEmoji("👍") {
    return errors.New("invalid emoji")
}

if !validation.IsValidMetadataKey("my-key_123") {
    return errors.New("key must be alphanumeric with hyphens/underscores")
}

Design Principles

Validation in this package follows these principles:

  • Fail fast: Validate before making API calls
  • Clear errors: Messages explain what's wrong and the valid range
  • Prevent API errors: Catch issues before they reach Linear's API

This approach improves user experience by providing immediate feedback rather than waiting for round-trip API errors.

Index

Constants

View Source
const (
	// MaxTitleLength is the maximum length for issue titles in Linear
	MaxTitleLength = 255
	// MaxDescriptionLength is the maximum length for descriptions in Linear
	MaxDescriptionLength = 100000
	// MaxNotificationLimit is the maximum number of notifications that can be fetched
	MaxNotificationLimit = 100
)

Constants for validation limits

Variables

This section is empty.

Functions

func IsValidEmoji

func IsValidEmoji(emoji string) bool

isValidEmoji checks if a string is a single valid emoji

func IsValidMetadataKey

func IsValidMetadataKey(key string) bool

isValidMetadataKey validates that a metadata key follows proper naming conventions Valid keys must: - Not be empty - Start with a letter or underscore - Contain only letters, numbers, underscores, or hyphens

func ValidatePositiveIntWithRange

func ValidatePositiveIntWithRange(value int, fieldName string, min, max int) error

validatePositiveIntWithRange validates that an integer is positive and within range

func ValidateStringLength

func ValidateStringLength(value, fieldName string, maxLength int) error

validateStringLength validates that a string is within acceptable length limits

Types

This section is empty.

Jump to

Keyboard shortcuts

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