validate

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alpha

func Alpha(s string) (string, error)

func Alphanumeric

func Alphanumeric(s string) (string, error)

func Contains

func Contains(s string, substr string) (string, error)

func Email

func Email(s string) (string, error)

func EndsWith

func EndsWith(s string, suffix string) (string, error)

func InRange

func InRange(n int, min int, max int) (int, error)

func InRangeFloat

func InRangeFloat(n float64, min float64, max float64) (float64, error)

func Length

func Length(s string, n int) (string, error)

func LengthBetween

func LengthBetween(s string, min int, max int) (string, error)

func ListMaxLength

func ListMaxLength(items []any, n int) ([]any, error)

func ListMinLength

func ListMinLength(items []any, n int) ([]any, error)

func Matches

func Matches(s string, pattern string) (string, error)

func Max

func Max(n int, max int) (int, error)

func MaxLength

func MaxLength(s string, n int) (string, error)

func Min

func Min(n int, min int) (int, error)

func MinLength

func MinLength(s string, n int) (string, error)

func Negative

func Negative(n int) (int, error)

func NoHTML

func NoHTML(s string) (string, error)

func NoNullBytes

func NoNullBytes(s string) (string, error)

func NoWhitespace

func NoWhitespace(s string) (string, error)

func NonNegative

func NonNegative(n int) (int, error)

func NonZero

func NonZero(n int) (int, error)

func NotEmpty

func NotEmpty(s string) (string, error)

func NotEmptyList

func NotEmptyList(items []any) ([]any, error)

func Numeric

func Numeric(s string) (string, error)

func OneOf

func OneOf(s string, allowed ...string) (string, error)

func ParseBool

func ParseBool(s string) (bool, error)

func ParseFloat

func ParseFloat(s string) (float64, error)

func ParseInt

func ParseInt(s string) (int, error)

func ParsePositiveInt

func ParsePositiveInt(s string) (int, error)

func Positive

func Positive(n int) (int, error)

func PositiveFloat

func PositiveFloat(n float64) (float64, error)

func Require

func Require(s string, fieldName string) (string, error)

func SafeFilename

func SafeFilename(s string) (string, error)

func StartsWith

func StartsWith(s string, prefix string) (string, error)

func URL

func URL(s string) (string, error)

func WithMessage

func WithMessage(value string, err error, message string) (string, error)

Types

type FieldError added in v0.8.9

type FieldError struct {
	Path    string
	Rule    string
	Message string
}

func CheckEmail added in v0.8.9

func CheckEmail(path string, s string) (FieldError, bool)

func CheckLen added in v0.8.9

func CheckLen(path string, length int, want int) (FieldError, bool)

func CheckMax added in v0.8.9

func CheckMax(path string, n int, max int) (FieldError, bool)

func CheckMaxLen added in v0.8.9

func CheckMaxLen(path string, length int, max int) (FieldError, bool)

func CheckMin added in v0.8.9

func CheckMin(path string, n int, min int) (FieldError, bool)

func CheckMinLen added in v0.8.9

func CheckMinLen(path string, length int, min int) (FieldError, bool)

func CheckNonEmpty added in v0.8.9

func CheckNonEmpty(path string, s string) (FieldError, bool)

func CheckNonEmptyLen added in v0.8.9

func CheckNonEmptyLen(path string, length int) (FieldError, bool)

func CheckNonZero added in v0.8.9

func CheckNonZero(path string, n int) (FieldError, bool)

func CheckOneOf added in v0.8.9

func CheckOneOf(path string, s string, allowed []string) (FieldError, bool)

func CheckRegex added in v0.8.9

func CheckRegex(path string, s string, pattern string) (FieldError, bool)

func CheckURL added in v0.8.9

func CheckURL(path string, s string) (FieldError, bool)

func RunIfValidatable added in v0.8.9

func RunIfValidatable(v any) []FieldError

func RunTags added in v0.8.9

func RunTags(v any) []FieldError

type TagValidatable added in v0.8.9

type TagValidatable interface {
	ValidateTags() []FieldError
}

type Validatable added in v0.8.9

type Validatable interface {
	Validate() []FieldError
}

Jump to

Keyboard shortcuts

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