validator

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default maximum file size (25MB)
	DefaultMaxFileSize int64 = 25 * 1024 * 1024

	// Allowed file formats
	AllowedImageFormats = map[string]bool{
		".jpg":  true,
		".jpeg": true,
		".png":  true,
		".gif":  true,
		".webp": true,
		".bmp":  true,
		".tiff": true,
		".svg":  true,
	}

	// Allowed MIME types
	AllowedMimeTypes = map[string]bool{
		"image/jpeg":      true,
		"image/png":       true,
		"image/gif":       true,
		"image/webp":      true,
		"image/bmp":       true,
		"image/tiff":      true,
		"image/svg+xml":   true,
		"application/pdf": true,
	}
)

Functions

func ValidateFile

func ValidateFile(file *multipart.FileHeader) error

ValidateFile performs file validation

func ValidateFileContent

func ValidateFileContent(content []byte) error

ValidateFileContent validates file content

func ValidateStruct

func ValidateStruct(s interface{}) error

ValidateStruct validates a struct using validator tags

Types

type FileValidationError

type FileValidationError struct {
	Code    string
	Message string
}

FileValidationError custom error type

func (*FileValidationError) Error

func (e *FileValidationError) Error() string

Jump to

Keyboard shortcuts

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