validation

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidWebURL

func IsValidWebURL(u *url.URL) bool

IsValidWebURL performs lightweight validation for web URLs (backward compatibility)

func ValidateURL

func ValidateURL(ctx context.Context, rawURL string, opts ValidationOptions) error

ValidateURL performs comprehensive URL validation with configurable options This is the main entry point that consolidates all validation logic

func ValidateURLSimple

func ValidateURLSimple(rawURL string) error

ValidateURLSimple performs basic URL validation without network checks Useful for quick validation where SSRF protection isn't needed

Types

type ValidationError

type ValidationError struct {
	Type    string
	Message string
	URL     string
}

ValidationError represents a URL validation error with specific type information

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationOptions

type ValidationOptions struct {
	AllowPrivateNetworks bool
	AllowLocalhost       bool
	RequireHTTPS         bool
	MaxHostnameLength    int
	Timeout              time.Duration
}

ValidationOptions configures URL validation behavior

func DefaultValidationOptions

func DefaultValidationOptions() ValidationOptions

DefaultValidationOptions returns secure defaults for URL validation

Jump to

Keyboard shortcuts

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