validators

package
v0.0.0-...-517d9f4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package validators Time : 2022/8/17 23:04 Author : xushiyin contact : [email protected]

Package validators Time : 2022/8/17 23:20 Author : xushiyin contact : [email protected]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateMap

func ValidateMap(m map[string]interface{}, mapRule validation.MapRule) error

Types

type Addr

type Addr struct {
	Street string `validate:"required"`
	City   string `validate:"required"`
	Planet string `validate:"required"`
	Phone  string `validate:"required"`
}

Addr houses a users address information

type Address

type Address struct {
	Street string `json:"street"`
	City   string `json:"city"`
	State  string `json:"state"`
	Zip    string `json:"zip"`
}

func (Address) Validate

func (a Address) Validate() error

type Customer

type Customer struct {
	Name    string  `json:"name"`
	Gender  string  `json:"gender"`
	Email   string  `json:"email"`
	Address Address `json:"address"`
}

func (Customer) Validate

func (c Customer) Validate() error

type DbBackedUser

type DbBackedUser struct {
	Name sql.NullString `validate:"required,gte=0"`
	Age  sql.NullInt64  `validate:"required"`
}

DbBackedUser User struct

type Employee

type Employee struct {
	Name string
}

type Eps

type Eps struct {
	Name   string   `json:"name"`
	Emails []string `json:"emails"`
}

func (Eps) Validate

func (e Eps) Validate() error

type Manager

type Manager struct {
	Employee
	Level int
}

type User

type User struct {
	FirstName      string  `json:"fname" validate:"required"`
	LastName       string  `json:"lname" validate:"required"`
	Age            uint8   `validate:"gte=0,lte=130"`
	Email          string  `json:"e-mail" validate:"required,email"`
	FavouriteColor string  `validate:"iscolor"`                // alias for 'hexcolor|rgb|rgba|hsl|hsla'
	Addresses      []*Addr `validate:"required,dive,required"` // a person can have a home and cottage...
}

User contains user information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳