validate

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2017 License: MIT Imports: 6 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 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) AddFailure

func (r *Result) AddFailure(message string)

AddFailure as a general message

func (*Result) AddFieldFailure

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

AddFieldFailure add failure message to specific field

type Validatable

type Validatable interface {
	Validate(services *app.Services) *Result
	IsAuthorized(user *models.User) 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