Documentation ¶
Index ¶
- Variables
- func CheckEmail(email string) bool
- func CheckPhone(phone string) bool
- func CheckUserName(userName string) (bool, string)
- type ErrorResponse
- type Validator
- func (v *Validator) ConnectCustom()
- func (v *Validator) Register(key string, fn validator.Func, callValidationEvenIfNull ...bool)
- func (v *Validator) RegisterTagName()
- func (v *Validator) ValidateMap(ctx context.Context, m map[string]interface{}, rules map[string]interface{}, ...) []*ErrorResponse
- func (v *Validator) ValidateStruct(ctx context.Context, s interface{}, languages ...string) []*ErrorResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( PhoneWithCountryCodeRegexp = "^\\+[0-9]{1,3}[0-9]{3}[0-9]{3}[0-9]{4}$" // +1-123-456-7890, +90-123-456-7890, +123-123-456-7890 LocationRegexp = "^[0-9]{1,3}\\.[0-9]{1,3}$" // 123.123 )
Functions ¶
func CheckEmail ¶
func CheckPhone ¶
func CheckUserName ¶
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { // Field is the field name. Field string `json:"field"` // Message is the error message. Message string `json:"message"` // Namespace is the namespace of the error. Namespace string `json:"namespace,omitempty"` // Value is the value of the field. Value interface{} `json:"value"` }
ErrorResponse is the error response structure.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is the validation structure.
func (*Validator) ConnectCustom ¶
func (v *Validator) ConnectCustom()
RegisterDefault registers the default validations.
func (*Validator) RegisterTagName ¶
func (v *Validator) RegisterTagName()
RegisterTagName registers the tag name.
func (*Validator) ValidateMap ¶
func (v *Validator) ValidateMap(ctx context.Context, m map[string]interface{}, rules map[string]interface{}, languages ...string) []*ErrorResponse
ValidateMap validates the giveb struct.
func (*Validator) ValidateStruct ¶
func (v *Validator) ValidateStruct(ctx context.Context, s interface{}, languages ...string) []*ErrorResponse
ValidateStruct validates the given struct.
Click to show internal directories.
Click to hide internal directories.