gomal

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValidationResult

type ValidationResult struct {
	Name     string
	Messages []string
}

func Validate

func Validate(validators ...Validator) []ValidationResult

type Validator

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

func If

func If(name string, value any) Validator

func (Validator) Between

func (validator Validator) Between(min, max any, option ...ValidatorOption) Validator

Only work for numerical data type (int, uint, and float)

func (Validator) Email

func (validator Validator) Email(option ...ValidatorOption) Validator

Only work for string

func (Validator) Empty

func (validator Validator) Empty(option ...ValidatorOption) Validator

func (Validator) Equal

func (validator Validator) Equal(another any, option ...ValidatorOption) Validator

func (Validator) GreaterThan

func (validator Validator) GreaterThan(another any, option ...ValidatorOption) Validator

Only work for numerical data type (int, uint, and float)

func (Validator) GreaterThanOrEqual

func (validator Validator) GreaterThanOrEqual(another any, option ...ValidatorOption) Validator

Only work for numerical data type (int, uint, and float)

func (Validator) Is added in v0.0.4

func (validator Validator) Is(callback func() (bool, string), option ...ValidatorOption) Validator

func (Validator) Length

func (validator Validator) Length(min, max int, option ...ValidatorOption) Validator

Only work for string

func (Validator) LessThan

func (validator Validator) LessThan(another any, option ...ValidatorOption) Validator

Only work for numerical data type (int, uint, and float)

func (Validator) LessThanOrEqual

func (validator Validator) LessThanOrEqual(another any, option ...ValidatorOption) Validator

Only work for numerical data type (int, uint, and float)

func (Validator) MaxLength

func (validator Validator) MaxLength(max int, option ...ValidatorOption) Validator

Only work for string

func (Validator) MinLength

func (validator Validator) MinLength(min int, option ...ValidatorOption) Validator

Only work for string

func (Validator) Nil

func (validator Validator) Nil(option ...ValidatorOption) Validator

func (Validator) NotEmpty

func (validator Validator) NotEmpty(option ...ValidatorOption) Validator

func (Validator) NotEqual

func (validator Validator) NotEqual(another any, option ...ValidatorOption) Validator

func (Validator) NotNil

func (validator Validator) NotNil(option ...ValidatorOption) Validator

func (Validator) RegExp

func (validator Validator) RegExp(expr string, option ...ValidatorOption) Validator

Only work for string

func (Validator) Unwrap added in v0.0.3

func (validator Validator) Unwrap() Validator

Unwrap if value is pointer

func (Validator) When

func (validator Validator) When(condition bool) Validator

type ValidatorOption added in v0.0.4

type ValidatorOption struct {
	ErrorMessage string
}

Jump to

Keyboard shortcuts

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