validator

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Female gender female.
	Female = 0
	// Male gender male.
	Male = 1
)

Variables

View Source
var (
	// ErrUnexpected unexpected error.
	ErrUnexpected = errors.New("参数校验出错")
)

Functions

func ParseErr

func ParseErr(err error) string

ParseErr parses the content of validation error.

func Verify

func Verify(obj interface{}) error

Verify checks the data validity of the exportable field of the structure according to the validate tag.

func VerifyVar added in v1.0.1

func VerifyVar(field interface{}, tag string) error

VerifyVar checks the data validity of the field according to the validate tag.

func VerifyVarWithValue added in v1.0.1

func VerifyVarWithValue(field, other interface{}, tag string) error

VerifyVarWithValue checks the data validity of the field against another field according to the validate tag.

Types

type BankCard

type BankCard string

BankCard bank card validator.

func NewBankCard

func NewBankCard(bankcard string) BankCard

NewBankCard new a bank card validator.

func (BankCard) IsValid

func (bc BankCard) IsValid() bool

IsValid checks the bank card is valid.

type CorpAccount

type CorpAccount string

CorpAccount corp account validator.

func NewCorpAccount

func NewCorpAccount(corpaccount string) CorpAccount

NewCorpAccount new a corp account validator.

func (CorpAccount) IsValid

func (ca CorpAccount) IsValid() bool

IsValid checks the corp account is valid.

type IdCard

type IdCard string

IdCard id card validator.

func NewIdCard

func NewIdCard(idcard string) IdCard

NewIdCard new an id card validator.

func (IdCard) GetBirthday

func (ic IdCard) GetBirthday() (time.Time, error)

GetBirthday gets the birthday recorded on id card.

func (IdCard) GetGender

func (ic IdCard) GetGender() (int, error)

GetGender gets the gender recorded on id card.

func (IdCard) IsFemale

func (ic IdCard) IsFemale() (bool, error)

IsFemale judges whether it is female.

func (IdCard) IsMale

func (ic IdCard) IsMale() (bool, error)

IsMale judges whether it is male.

func (IdCard) IsValid

func (ic IdCard) IsValid() bool

IsValid checks the id card is valid.

type USCC

type USCC string

USCC uscc validator.

func NewUSCC

func NewUSCC(uscc string) USCC

NewUSCC new an uscc validator.

func (USCC) IsValid

func (uscc USCC) IsValid() bool

IsValid checks the uscc is valid.

Jump to

Keyboard shortcuts

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