validate

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Ok         bool
	Authorized bool
	Error      error
	Messages   []string
	Failures   map[string][]string
}

Result is returned after each validation

func CNAME added in v0.8.0

func CNAME(tenants storage.Tenant, cname string) *Result

CNAME validates given cname

func Email added in v0.6.0

func Email(email string) *Result

Email validates given email address

func Error

func Error(err error) *Result

Error returns a failed validation result

func Failed

func Failed(messages []string) *Result

Failed returns a failed validation result

func Subdomain

func Subdomain(tenants storage.Tenant, subdomain string) *Result

Subdomain validates given subdomain

func Success

func Success() *Result

Success returns a successful validation

func Unauthorized

func Unauthorized() *Result

Unauthorized returns an unauthorized validation result

func (*Result) AddFieldFailure

func (r *Result) AddFieldFailure(field string, messages ...string)

AddFieldFailure add failure message to specific field

type Validatable

type Validatable interface {
	Validate(user *models.User, services *app.Services) *Result
	IsAuthorized(user *models.User, services *app.Services) bool
}

Validatable defines which models can be validated against context

Jump to

Keyboard shortcuts

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