validation

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExcludeChars

func ExcludeChars(fieldName, value, chars string) error

ExcludeChars makes sure there characters in a field are valid

func IntIn

func IntIn(check int, others ...int) error

func IsIP

func IsIP(value string) error

IsIP checks to see if the value is a valid IP address. Returns an error if not valid

func IsSubnet16

func IsSubnet16(value string) error

IsSubnet16 checks to see if the value is a valid /16 subnet. Returns an error if not valid

func IsSubnetCIDR

func IsSubnetCIDR(value string) error

IsSubnetCIDR checks to see if the value is a valid cidr subnet. Returns an error if not valid

func NotEmpty

func NotEmpty(fieldName string, value string) error

NotEmpty check to see if the value is not an empty string or a string with just whitespace characters, returns an error if empty. FieldName is used to create a meaningful error

func StringIn

func StringIn(check string, others ...string) error

StringsEqual checks to see that strings are equal, optional msg to use instead of default

func StringsEqual

func StringsEqual(expected string, other string, errMsg string) error

StringsEqual checks to see that strings are equal, optional msg to use instead of default

func ValidHostID

func ValidHostID(hostID string) error

func ValidPoolId

func ValidPoolId(poolID string) error

func ValidPort

func ValidPort(port int) error

func ValidUIAddress

func ValidUIAddress(addr string) error

func ValidVirtualIP

func ValidVirtualIP(bindInterface string) error

Types

type ValidationError

type ValidationError struct {
	Errors []error
}

ValidationError is an error that contains other errors

func NewValidationError

func NewValidationError() *ValidationError

NewValidationError creates a ValidationError with an empty slice of errors

func (*ValidationError) Add

func (v *ValidationError) Add(err error)

Add adds a an error

func (*ValidationError) AddViolation

func (v *ValidationError) AddViolation(violationMsg string)

AddViolation adds Violation error

func (*ValidationError) Error

func (v *ValidationError) Error() string

Error returns the error string

func (*ValidationError) HasError

func (v *ValidationError) HasError() bool

HasError test to see if length of Errors slice is greater than 0

type Violation

type Violation struct {
	// contains filtered or unexported fields
}

Violation is an error type for validation violations

func NewViolation

func NewViolation(msg string) *Violation

NewViolation creates a violation error

func (*Violation) Error

func (v *Violation) Error() string

Error returns the error string

Jump to

Keyboard shortcuts

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