Documentation ¶
Index ¶
- Variables
- func IsAlphanumeric(str string) bool
- func IsDNSName(str string) bool
- func IsHostPort(str string) bool
- func IsIP(str string) bool
- func IsPort(str string) bool
- func Validate(conf *Config, fns ...Fn) (err error)
- type Config
- type Fn
- func Map[T any](items map[string]T, fn func(refId string, item T) error) Fn
- func MapNotNil[K comparable, V any](prop string, values map[K]V) Fn
- func MapRequired[K comparable, V any](prop string, values map[K]V) Fn
- func NumberGreaterThan[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](prop string, value T, target T) Fn
- func NumberGreaterThanOrEqual[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](prop string, value T, target T) Fn
- func NumberInRange[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](prop string, value T, min, max T) Fn
- func NumberLessThan[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](prop string, value T, target T) Fn
- func NumberLessThanOrEqual[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](prop string, value T, target T) Fn
- func PointerNotNil[T any](prop string, value *T) Fn
- func Slice[T any](items []T, fn func(i int, item *T) error) Fn
- func SliceRequired[T any](prop string, values []T) Fn
- func StringAlphanumeric(prop, value string) Fn
- func StringHostPort(prop, value string) Fn
- func StringIn(prop string, values []string, in []string) Fn
- func StringLen(prop, value string, min, max int) Fn
- func StringLenIfNotEmpty(prop, value string, min, max int) Fn
- func StringOneOf(prop, value string, oneOf []string) Fn
- func StringRequired(prop, value string) Fn
- func StringStartsWith(prop, value, prefix string) Fn
- func StringStartsWithIfNotEmpty(prop, value, prefix string) Fn
- func StringStartsWithOneOf(prop, value string, prefixes []string) Fn
- func StringUri(prop, value string) Fn
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Alphanumeric string = "^[a-zA-Z0-9]+$"
)
View Source
var (
DNSName string = `^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$`
)
View Source
var DefaultConfig = &Config{ StopAtFirstError: true, }
Functions ¶
func IsAlphanumeric ¶
IsAlphanumeric checks if the string contains only letters and numbers. Empty string is invalid.
func IsHostPort ¶
IsHostPort validates the given string for usage with the various Dial() functions
Types ¶
type Fn ¶
type Fn func() error
func MapRequired ¶
func MapRequired[K comparable, V any](prop string, values map[K]V) Fn
func NumberGreaterThan ¶
func NumberInRange ¶
func NumberLessThan ¶
func NumberLessThanOrEqual ¶
func PointerNotNil ¶
func SliceRequired ¶
func StringAlphanumeric ¶
func StringHostPort ¶
func StringLenIfNotEmpty ¶
func StringOneOf ¶
func StringRequired ¶
func StringStartsWith ¶
func StringStartsWithOneOf ¶
Click to show internal directories.
Click to hide internal directories.