validator

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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