validators

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExistsOrError

func ExistsOrError(fpath string, isFileExists FileExistsFunc) error

ExistsOrError checks if the file specified by fpath exists.

It returns an error if the file does not exist.

func ExtensionOrError

func ExtensionOrError(parts *[]string, filename string) error

ExtensionOrError checks if the filename has a valid extension.

It expects parts to contain two elements: the filename and its extension. Returns an error if the filename doesn't have a valid extension format.

func SupportedOrError

func SupportedOrError(extension string) error

SupportedOrError checks if the provided extension is among the supported ones.

It compares the extension parameter against a predefined list of valid extensions (jpg, jpeg, png). Returns an error if the extension is not supported.

func ValidateSize

func ValidateSize(size string) error

ValidateSize validates the format of the size string.

It checks if the size string matches the `<width>x<height>` format using a regular expression. Returns an error if the size string is empty, doesn't match the expected format, or if there was an error compiling the regular expression.

Types

type FileExistsFunc

type FileExistsFunc func(fpath string) bool

FileExistsFunc is an interface that abstracts the IsFileExists function.

Jump to

Keyboard shortcuts

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