validation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEmail

func ValidateEmail(email string) (bool, error)

func ValidatePhoneNumber

func ValidatePhoneNumber(phoneNumber, region string) bool

Types

type Validator

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

func New

func New() *Validator

func NewWithPhoneRegion added in v1.0.0

func NewWithPhoneRegion(phoneRegion string) *Validator

NewWithPhoneRegion builds a Validator whose "phonenumber" struct-tag validator parses numbers against phoneRegion (a libphonenumber region code, e.g. "GH") instead of the hardcoded "NG" default. The underlying ValidatePhoneNumber function has always been region-aware — this was the only call site that hardcoded a region.

A single *validator.Validate instance only supports one registered "phonenumber" region at a time, so a multi-country app validating phone numbers for users in different countries within the same process should construct one Validator per resolved region as needed (e.g. per-request, keyed by the caller's resolved country), rather than relying on a single process-wide default.

func (*Validator) GetValidate

func (v *Validator) GetValidate() *validator.Validate

func (*Validator) Validate

func (v *Validator) Validate(i any) error

Jump to

Keyboard shortcuts

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