validate

package
v0.0.0-...-b497a26 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(in any, out any, fields Fields) bool

func ValidatePassword

func ValidatePassword(password string) (string, bool)

validatePassword checks if the password is strong and meets the criteria: - At least 8 characters long - Contains at least one digit - Contains at least one lowercase letter - Contains at least one uppercase letter - Contains at least one special character

Types

type Fields

type Fields map[string][]RuleSet

type Messages

type Messages map[string]string

type RuleFunc

type RuleFunc func() RuleSet

func Equal

func Equal(s string) RuleFunc

func Max

func Max(n int) RuleFunc

func Message

func Message(msg string) RuleFunc

func Min

func Min(n int) RuleFunc

type RuleSet

type RuleSet struct {
	Name         string
	RuleValue    any
	FieldValue   any
	FieldName    any
	MessageFunc  func(RuleSet) string
	ValidateFunc func(RuleSet) bool
}

func Email

func Email() RuleSet

func Password

func Password() RuleSet

func Required

func Required() RuleSet

func Rules

func Rules(rules ...RuleFunc) []RuleSet

func Url

func Url() RuleSet

type Validator

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

func New

func New(data any, fields Fields) *Validator

func (*Validator) Validate

func (v *Validator) Validate(target any) bool

Jump to

Keyboard shortcuts

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