Documentation
¶
Index ¶
- Variables
- func AllIn[T comparable](values []T, safelist ...T) bool
- func Between[T constraints.Ordered](value, min, max T) bool
- func CleanPhoneNumber(phone string) string
- func FormatIndonesianPhoneNumber(phone string) string
- func In[T comparable](value T, safelist ...T) bool
- func IsEmail(value string) bool
- func IsIndonesianPhoneNumber(phone string) bool
- func IsInternationalPhoneNumber(phone string) bool
- func IsNotAdminInput(value string) bool
- func IsNotSuperAdminInput(value string) bool
- func IsPhoneNumber(phone string) bool
- func IsURL(value string) bool
- func Matches(value string, rx *regexp.Regexp) bool
- func MaxRunes(value string, n int) bool
- func MinRunes(value string, n int) bool
- func NoDuplicates[T comparable](values []T) bool
- func NotBlank(value string) bool
- func NotIn[T comparable](value T, blocklist ...T) bool
- func ValidateAndFormatPhone(phone string) (string, error)
- func ValidatePhone(phone string) (string, []string)
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // RgxPhoneBasic Basic international phone number pattern RgxPhoneBasic = regexp.MustCompile(`^\+?[0-9]{10,15}$`) // RgxPhoneIndonesia Indonesian phone number pattern (more specific) RgxPhoneIndonesia = regexp.MustCompile(`^(\+62|62|0)8[1-9][0-9]{6,9}$`) // RgxPhoneInternational International phone number pattern (more comprehensive) RgxPhoneInternational = regexp.MustCompile(`^\+(?:[0-9]●?){6,14}[0-9]$`) )
View Source
var (
RgxEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
)
Functions ¶
func AllIn ¶
func AllIn[T comparable](values []T, safelist ...T) bool
func Between ¶
func Between[T constraints.Ordered](value, min, max T) bool
func CleanPhoneNumber ¶
CleanPhoneNumber removes all non-digit characters except '+'
func FormatIndonesianPhoneNumber ¶
FormatIndonesianPhoneNumber formats a phone number to Indonesian standard
func In ¶
func In[T comparable](value T, safelist ...T) bool
func IsIndonesianPhoneNumber ¶
IsIndonesianPhoneNumber validates specifically Indonesian phone numbers
func IsInternationalPhoneNumber ¶
IsInternationalPhoneNumber validates international phone numbers
func IsNotAdminInput ¶
func IsNotSuperAdminInput ¶
func IsPhoneNumber ¶
IsPhoneNumber validates a phone number using basic format
func NoDuplicates ¶
func NoDuplicates[T comparable](values []T) bool
func NotIn ¶
func NotIn[T comparable](value T, blocklist ...T) bool
func ValidateAndFormatPhone ¶
ValidateAndFormatPhone validates and formats a phone number
func ValidatePhone ¶
Types ¶
type Validator ¶
type Validator struct { Errors []string `json:",omitempty"` FieldErrors map[string]string `json:",omitempty"` }
func (*Validator) AddFieldError ¶
func (*Validator) CheckField ¶
Click to show internal directories.
Click to hide internal directories.