xvalidate

package
v2.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between(s string, min, max int) bool

Between reports whether the length of s is within [min, max].

func In

func In(v any, set any) bool

In reports whether v is contained in set. When v is a slice or an array, it reports whether any of its elements is in the set; otherwise it reports whether v equals an element of the set.

func IsAccount

func IsAccount(account string, min int, max int) bool

IsAccount reports whether account is a valid account name. An account starts with a letter, may then contain letters, digits, underscores, hyphens and dots, and its length must be between min and max inclusive.

func IsDigit

func IsDigit(digit string) bool

IsDigit reports whether digit is a valid numeric value. Positive and negative integers and floats are supported, but leading zeros and scientific notation are not.

func IsEmail

func IsEmail(email string) bool

IsEmail reports whether email is a valid email address.

func IsIdCard added in v2.1.0

func IsIdCard(idCard string) bool

IsIdCard reports whether idCard is a valid Chinese 18-digit resident identity card number. It validates the address code, the birth date, the sequence code and the check code.

The check-code algorithm is taken from https://zhuanlan.zhihu.com/p/608188853.

func IsMobile

func IsMobile(mobile string) bool

IsMobile reports whether mobile is a Chinese mobile phone number. It validates an 11-digit number covering the 13, 14, 15, 16, 17, 18 and 19 prefixes.

func IsNumber

func IsNumber(number string, langths ...int) bool

IsNumber reports whether number consists only of digits. Its length may optionally be constrained: a single langths argument requires an exact length, while two arguments require a minimum and a maximum length.

func IsQQ

func IsQQ(qq string) bool

IsQQ reports whether qq is a valid QQ number. A QQ number has at least 5 digits and its first digit is not zero.

func IsTelephone

func IsTelephone(telephone string) bool

IsTelephone reports whether telephone is a fixed-line phone number. It accepts formats with an area code, such as 028-5554540 or 0285-55545401, as well as 7- to 8-digit numbers without one.

func IsUrl

func IsUrl(url string) bool

IsUrl reports whether url is a valid URL. The http, https, ftp and file schemes are supported and matched case-insensitively.

func Length

func Length(s string, n int) bool

Length reports whether the length of s equals n.

func MaxLength

func MaxLength(s string, n int) bool

MaxLength reports whether the length of s is at most n.

func MinLength

func MinLength(s string, n int) bool

MinLength reports whether the length of s is at least n.

Types

This section is empty.

Jump to

Keyboard shortcuts

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