rules

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REQUIRED         = "required"
	TYPE             = "type"
	LENGTH           = "length"
	MIN_LENGTH       = "minlength"
	MAX_LENGTH       = "maxlength"
	EMAIL_VALIDATION = "email"
	DATE_VALIDATION  = "date"
	ARRAY_LEN        = "slice:len"
	ARRAY_MIN_LEN    = "slice:minlen"
	ARRAY_MAX_LEN    = "slice:maxlen"
)

Variables

This section is empty.

Functions

func GetType

func GetType[T comparable]() string

Types

type FieldError

type FieldError interface {
	Name() string
	Message() string
	RuleType() string
}

func NewErrorByField

func NewErrorByField(ruleType, fieldName, argument string) FieldError

type Rule

type Rule interface {
	Type() string
	Description() string
	Validator() validatorFunc
	Argument() string
	IsValid(value interface{}) bool
	GenerateError(fieldName string) FieldError
	IsSliceRule() bool
}

func GetRuleByHint

func GetRuleByHint(hint string) Rule

func GetTypeValidator

func GetTypeValidator(key string) Rule

func NewRequiredRule

func NewRequiredRule(argument string) Rule

func NewSliceRule

func NewSliceRule[T comparable]() Rule

func NewTypeRule

func NewTypeRule[T comparable]() Rule

func NewTypeRuleWithMethod

func NewTypeRuleWithMethod(method validatorFunc) Rule

Jump to

Keyboard shortcuts

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