validate

package module
v0.0.0-...-ea2cf8c Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: MIT Imports: 8 Imported by: 0

README

Validate

(WORK-IN-PROGRESS) A golang package for simple validation of email addresses. This package is to be used along with sending a confirmation mail.

Installation

    go get -u github.com/knocus/validate

Usage

    import (
	    "github.com/knocus/validate"
	)
	func main(){
		err := validate.Email("some.email@gmail.com");
		if(err == nil){
			/* send confirmation link / other logic here */
 		} else {
			/* prompt the user about error / ask email again. */
		}
    }

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LowerCase        = constraint{"LOWER_CASE"}
	UpperCase        = constraint{"UPPER_CASE"}
	Number           = constraint{"NUMBER"}
	SpecialCharacter = constraint{"SPECIAL_CHARACTER"}
)
View Source
var (
	ErrInvalidEmail = errors.New("Invalid email address")
)

Functions

func Email

func Email(email string) error

func ParseHost

func ParseHost(email string) (host string, err error)

Types

type FacebookAuthenticateSuccessResponse

type FacebookAuthenticateSuccessResponse struct {
	Token       string   `json:"token"`
	AppID       string   `json:"app_id"`
	Type        string   `json:"type"`
	Application string   `json:"application"`
	ExpiresAt   int64    `json:"expires_at"`
	IsValid     bool     `json:"is_valid"`
	Scopes      []string `json:"scopes"`
	UserID      string   `json:"user_id"`
}

type FacebookConfig

type FacebookConfig struct {
	Token        string `url:"token"`
	ClientID     string `url:"client_id"`
	ClientSecret string `url:"client_secret"`
	GrantType    string `url:"grant_type"`
	RedirectURI  string `url:"redirect_uri"`
	Scope        string `url:"scope"`
}

type GoogleAuthenticateSuccessResponse

type GoogleAuthenticateSuccessResponse struct {
	// Verify that it is issued by accounts.google.com or
	// https://accounts.google.com.
	IssuedBy string `json:"iss"`

	// An identifier for the user, unique among all Google accounts and never reused.
	// A Google account can have multiple emails at different points in time,
	// but the sub value is never changed.
	// Use sub within your application as the unique-identifier key for the user.
	UserID string `json:"sub"`

	// Client ID of Android
	AndroidAudience string `json:"azp"`

	// Client ID of web
	Audience string `json:"aud"`

	// Convert this to int64 at runtime.
	// Unix Timestamp with double quotes returned.
	// Eg: iat: "1433981153"
	IssuedAt string `json:"iat"`

	// Conver this to int64 at runtime.
	// Unix Timestamp with double quotes returned.
	// Eg: exp: "1433981953"
	ExpiresAt string `json:"exp"`

	// These seven fields are only included when the user has granted the "profile" and
	// "email" OAuth scopes to the application.
	Email string `json:"email"`

	//Convert this to bool at runtime.
	// email_verified :"true" or email_verified: "false"
	IsEmailVerified string `json:"email_verified"`

	// Name as displayed on Google profiles
	DisplayName string `json:"name"`

	// URL to the current display pic
	DisplayPicture string `json:"picture"`

	// Given name / First name of the user
	FirstName string `json:"given_name"`

	// Family name / Last name  of the user
	LastName string `json:"family_name"`

	// Eg: locale: "en"
	Locale string `json:"locale"`
}

type GoogleConfig

type GoogleConfig struct {
	Token string `url:"id_token"`
}

type InspectTokenResponse

type InspectTokenResponse struct {
	Data FacebookAuthenticateSuccessResponse `json:"data"`
}

type PasswordConfig

type PasswordConfig func(*PasswordConfigs)

func MustContain

func MustContain(constraints []constraint) PasswordConfig

type PasswordConfigs

type PasswordConfigs struct {
	MustContain []constraint
	MinLength   int
	MaxLength   int
}

Jump to

Keyboard shortcuts

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