validate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValidationMessage

type ValidationMessage struct {
	Message string
	Field   string
}

ValidationMessage a struct that holds a message and the field that it relates to

func NewValidationMessage

func NewValidationMessage(field string, msg string) ValidationMessage

NewValidationMessage return a validation message

type ValidationResult

type ValidationResult struct {
	Pass     bool
	Messages []ValidationMessage
}

ValidationResult an object that holds the aggregated outcome of validation routines

func IsEmail

func IsEmail(field string, input string) ValidationResult

IsEmail return success if the string is a valid email format

func IsEqualTo

func IsEqualTo(field string, value1 string, value2 string) ValidationResult

IsEqualTo return success if the two values passed in are equal

func IsGreaterThan

func IsGreaterThan(field string, input int, target int) ValidationResult

IsGreaterThan return success if the value of the number is less than the maximum

func IsIP

func IsIP(field string, input string) ValidationResult

IsIP return success if the string is a valid IP format

func IsLengthGreaterThan

func IsLengthGreaterThan(field string, input string, target int) ValidationResult

IsLengthGreaterThan return success if the length of the string is greater than the minimum

func IsLengthLessThan

func IsLengthLessThan(field string, input string, target int) ValidationResult

IsLengthLessThan return success if the length of the string is less than the maximum

func IsLessThan

func IsLessThan(field string, input int, target int) ValidationResult

IsLessThan return success if the value of the number is greater than the minimum

func IsNotEmpty

func IsNotEmpty(field string, input string) ValidationResult

IsNotEmpty return a passing result if the string has a valid value

func IsValidWebAddress

func IsValidWebAddress(field string, input string) ValidationResult

IsValidWebAddress return success if the string is a valid email format

func NewFailingValidationResult

func NewFailingValidationResult(msg ...ValidationMessage) ValidationResult

NewFailingValidationResult return a new validation result

func NewSuccessValidationResult

func NewSuccessValidationResult() ValidationResult

NewSuccessValidationResult return a new validation result

func SatisfiesRegex

func SatisfiesRegex(field string, re string) ValidationResult

SatisfiesRegex return success if the field entered satifies the passed in regex

func (*ValidationResult) Append

func (v *ValidationResult) Append(result ValidationResult)

Append aggregate the outcome of 2 validation results

func (*ValidationResult) Error

func (v *ValidationResult) Error(context string) error

Error if errors are available, return an aggregated single error

Jump to

Keyboard shortcuts

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