Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFileInvalidExtension = errors.New(
`extension validator: File has an invalid extension type`)
ErrFileInvalidExtension is an error type that is rendered when an extension is shown
var ErrFileInvalidMimeType = errors.New(`
mimetype validator: File has an invalid mimetype`)
ErrFileInvalidMimeType is an error type denoting a file with a mimetype unrecognized by the validator
var ErrFileSizeTooLarge = errors.New(`
size validator: File size is too large`)
ErrFileSizeTooLarge is an error type for files that signifies a file s too large
var ErrFileSizeTooSmall = errors.New(`
size validator: File size is too small`)
ErrFileSizeTooSmall is an error type that denotes a file is too small Thus the reason behind the validation's failure
Functions ¶
This section is empty.
Types ¶
type ChainedValidator ¶
type ChainedValidator struct {
// contains filtered or unexported fields
}
ChainedValidator is a validator that is composed of other validators It doesn't perform any validation itself instead it defers to the validators it has been composed of
func NewChainedValidator ¶
func NewChainedValidator(v ...Validator) *ChainedValidator
NewChainedValidator returns an instance of a ChainedValidator. It panics if no validator is added to the chain
type ExtensionValidator ¶
type ExtensionValidator struct {
// contains filtered or unexported fields
}
ExtensionValidator is a validator that validates a file based on it's extension Extremely dumb and cannot be trusted
func NewExtensionValidator ¶
func NewExtensionValidator(allowedExtensions []string) *ExtensionValidator
NewExtensionValidator returns an instance of an ExtensionValidator
type MimeTypeValidator ¶
type MimeTypeValidator struct {
// contains filtered or unexported fields
}
MimeTypeValidator is a validator that checks the mimetype of a file and compares it to a list of acceptable mimetypes to determine wheter it is valid or not
func NewMimeTypeValidator ¶
func NewMimeTypeValidator(mimeTypes []string) *MimeTypeValidator
NewMimeTypeValidator returns an instance of a MimeTypeValidator
type SizeValidator ¶
type SizeValidator struct {
// contains filtered or unexported fields
}
SizeValidator is a validator that checks the size of a file to determine if it is valid or not based on predefined criterias
func NewSizeValidator ¶
func NewSizeValidator(maxSize, minSize int64) *SizeValidator
NewSizeValidator returns an instance of a SizeValidator maxSize and minSize are to be given in bytes