validator

package module
v0.0.0-...-b0c5adb Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 9 Imported by: 0

README

Gungun Validator

A simple and personal golang manual validation library made for me.

How run test

Use make test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBool

func ValidateBool(value any, rules BoolValidators) (bool, error)

func ValidateFloat

func ValidateFloat(value any, rules FloatValidators) (float64, error)

func ValidateInt

func ValidateInt(value any, rules IntValidators) (int, error)

func ValidateMapBool

func ValidateMapBool(name string, value map[string]any, rules BoolValidators) (bool, error)

func ValidateMapBoolOrFalse

func ValidateMapBoolOrFalse(
	name string,
	value map[string]any,
	rules BoolValidators,
) (bool, error)

func ValidateMapFloat

func ValidateMapFloat(name string, value map[string]any, rules FloatValidators) (float64, error)

func ValidateMapInt

func ValidateMapInt(name string, value map[string]any, rules IntValidators) (int, error)

func ValidateMapString

func ValidateMapString(name string, value map[string]any, rules StringValidators) (string, error)

func ValidateMapStringOrNil

func ValidateMapStringOrNil(
	name string,
	value map[string]any,
	rules StringValidators,
) (*string, error)

func ValidateMapTime

func ValidateMapTime(name string, value map[string]any, rules TimeValidators) (time.Time, error)

func ValidateMapTimeOrNil

func ValidateMapTimeOrNil(
	name string,
	value map[string]any,
	rules TimeValidators,
) (*time.Time, error)

func ValidateMapUUID

func ValidateMapUUID(name string, value map[string]any) (uuid.UUID, error)

func ValidateString

func ValidateString(value any, rules StringValidators) (string, error)

func ValidateTime

func ValidateTime(value any, rules TimeValidators) (time.Time, error)

func ValidateUUID

func ValidateUUID(value any) (uuid.UUID, error)

Types

type BoolIsFalseValidator

type BoolIsFalseValidator struct{}

func (BoolIsFalseValidator) Validate

func (v BoolIsFalseValidator) Validate(value bool) error

type BoolIsTrueValidator

type BoolIsTrueValidator struct{}

func (BoolIsTrueValidator) Validate

func (v BoolIsTrueValidator) Validate(value bool) error

type BoolValidators

type BoolValidators []boolValidator

type FloatMaxValidator

type FloatMaxValidator struct {
	Max float64
}

func (FloatMaxValidator) Validate

func (v FloatMaxValidator) Validate(value float64) error

type FloatMinValidator

type FloatMinValidator struct {
	Min float64
}

func (FloatMinValidator) Validate

func (v FloatMinValidator) Validate(value float64) error

type FloatValidators

type FloatValidators []floatValidator

type IntMaxValidator

type IntMaxValidator struct {
	Max int
}

func (IntMaxValidator) Validate

func (v IntMaxValidator) Validate(value int) error

type IntMinValidator

type IntMinValidator struct {
	Min int
}

func (IntMinValidator) Validate

func (v IntMinValidator) Validate(value int) error

type IntValidators

type IntValidators []intValidator

type StringEmailValidator

type StringEmailValidator struct{}

func (StringEmailValidator) Validate

func (v StringEmailValidator) Validate(value string) error

type StringMaxValidator

type StringMaxValidator struct {
	Max int
}

func (StringMaxValidator) Validate

func (v StringMaxValidator) Validate(value string) error

type StringMinValidator

type StringMinValidator struct {
	Min int
}

func (StringMinValidator) Validate

func (v StringMinValidator) Validate(value string) error

type StringPhoneValidator

type StringPhoneValidator struct{}

func (StringPhoneValidator) Validate

func (v StringPhoneValidator) Validate(value string) error

type StringValidators

type StringValidators []stringValidator

type TimeMaxValidator

type TimeMaxValidator struct {
	Max time.Time
}

func (TimeMaxValidator) Validate

func (v TimeMaxValidator) Validate(value time.Time) error

type TimeMinValidator

type TimeMinValidator struct {
	Min time.Time
}

func (TimeMinValidator) Validate

func (v TimeMinValidator) Validate(value time.Time) error

type TimeValidators

type TimeValidators []timeValidator

Jump to

Keyboard shortcuts

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