tovalidate

package
v5.1.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlphanumericDash

func IsAlphanumericDash(str string) bool

IsAlphanumericDash returns true if the string consists of only alphanumeric or dash characters.

func IsAlphanumericUnderscoreDash

func IsAlphanumericUnderscoreDash(str string) bool

IsAlphanumericUnderscoreDash returns true if the string consists of only alphanumeric, underscore, or dash characters.

func IsGreaterThanZero

func IsGreaterThanZero(value interface{}) error

func IsOneOfString

func IsOneOfString(set ...string) func(string) bool

IsOneOfString generates a validator function returning whether string is in the set of strings

func IsOneOfStringICase

func IsOneOfStringICase(set ...string) func(string) bool

IsOneOfStringICase is a case-insensitive version of IsOneOfString

func IsPtrToSliceOfUniqueStringersICase

func IsPtrToSliceOfUniqueStringersICase(set ...string) func(interface{}) error

IsPtrToSliceOfUniqueStringersICase returns a validator function which returns an error if the argument is a non-nil pointer to a slice of Stringers whose String() values are not in the set of strings or there are duplicate strings

func IsValidIPv6CIDROrAddress

func IsValidIPv6CIDROrAddress(value interface{}) error

func IsValidPortNumber

func IsValidPortNumber(value interface{}) error

func NoLineBreaks

func NoLineBreaks(str string) bool

NoLineBreaks returns true if the string has no line breaks.

func NoPeriods

func NoPeriods(str string) bool

NoPeriods returns true if the string has no periods

func NoSpaces

func NoSpaces(str string) bool

NoSpaces returns true if the string has no spaces

func StringIsValidFloat

func StringIsValidFloat() *validation.StringRule

StringIsValidFloat returns a reference to a validation.StringRule function that only returns true if the string value given string argument can be parsed to a 64-bit float that is not NaN.

func ToErrors

func ToErrors(err map[string]error) []error

ToErrors - Flips to an array of errors

Types

type DBExistsRule

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

DBExistsRule checks if value is in column in this table TODO: DBExistsRule ? what about DBUniqueRule?

func NewDBExistsRule

func NewDBExistsRule(db *sqlx.DB, table string, column string) *DBExistsRule

NewDBExistsRule is a validation rule that checks if the given value is in the column in this table

func (*DBExistsRule) Error

func (r *DBExistsRule) Error(message string) *DBExistsRule

Error sets the error message for the rule.

func (*DBExistsRule) Validate

func (r *DBExistsRule) Validate(value interface{}) error

Validate checks if the given value is valid or not.

type DBUniqueRule

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

DBUniqueRule checks if value is in column in this table TODO: DBUniqueRule ? what about DBUniqueRule?

func NewDBUniqueRule

func NewDBUniqueRule(db *sqlx.DB, table string, column string, idCheck func(int) bool) *DBUniqueRule

NewDBUniqueRule is a validation rule that checks if the given value is in the column in this table

func (*DBUniqueRule) Error

func (r *DBUniqueRule) Error(message string) *DBUniqueRule

Error sets the error message for the rule.

func (*DBUniqueRule) Validate

func (r *DBUniqueRule) Validate(value interface{}) error

Validate returns an error if the value already exists in the table in this column

Jump to

Keyboard shortcuts

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