validate

package
v0.92.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package validate provides shared validation rules and helpers for the application.

Index

Constants

View Source
const (
	// Text field limits
	TitleMaxLen = 200
	DescMaxLen  = 2000
	NameMaxLen  = 100

	// URL limits
	URLMaxLen = 2048

	// Tag limits
	TagMaxLen    = 50
	MaxTagsCount = 50
	MinTagLen    = 1

	// Query limits
	QueryMaxLen    = 100
	MaxSearchLimit = 100

	// File upload limits
	MaxFileSizeMB    = 10
	MaxFileSizeBytes = MaxFileSizeMB * 1024 * 1024
	MaxFileCount     = 10
)

Common validation constants

View Source
const (
	// Required title: non-empty, max 200 chars
	TagTitle = "required,min=1,max=200"

	// Optional title: if provided, max 200 chars
	TagTitleOptional = "omitempty,min=1,max=200"

	// Required description: non-empty, max 2000 chars
	TagDescription = "required,min=1,max=2000"

	// Optional description: if provided, max 2000 chars
	TagDescriptionOptional = "omitempty,max=2000"

	// Required URL: valid URL format, max 2048 chars
	TagURL = "required,url,max=2048"

	// Optional URL: if provided, valid URL format
	TagURLOptional = "omitempty,url,max=2048"

	// Positive integer ID (for IDs that must be > 0)
	TagID = "required,gte=1"

	// Optional positive integer ID
	TagIDOptional = "omitempty,gte=1"

	// Non-negative integer
	TagNonNegative = "gte=0"

	// Required non-empty string
	TagRequired = "required,min=1"

	// Tag list: required, each tag 1-50 chars, max 50 tags
	TagList = "required,dive,min=1,max=50"
)

Common validation tags for reuse in struct definitions

Variables

View Source
var Validate = validator.New()

Validate is the global validator instance

Functions

func ValidateVar

func ValidateVar(v any, tag string) error

ValidateVar validates a single variable against a tag

Types

This section is empty.

Jump to

Keyboard shortcuts

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