validations

package module
v0.0.0-...-3f5634b Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 9 Imported by: 5

README

Validations

Validations provides a means to validate GORM-backend models when creating and updating them.

Documentation

https://doc.getqor.com/plugins/validation.html

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PREFIX = path_helpers.GetCalledDir()
View Source
var VALIDATE_CALLBACK = PREFIX + ":validate"

Functions

func Failed

func Failed(resource interface{}, column, err string, path ...string) error

NewError generate a new error for a model's field

func FieldFailed

func FieldFailed(resource interface{}, fieldName, err string, path ...string) error

NewError generate a new error for a model's field

func IDToString

func IDToString(id aorm.ID) string

func IsError

func IsError(err ...error) bool

IsError returns if any error is Error type

func NewError

func NewError(resource interface{}, column, err string) error

NewError generate a new error for a model's field

func RegisterCallbacks

func RegisterCallbacks(db *aorm.DB) *aorm.DB

RegisterCallbacks register callback into GORM DB

func RegisteredCallbacks

func RegisteredCallbacks(db *aorm.DB) bool

func RegisteredCallbacksOrError

func RegisteredCallbacksOrError(db *aorm.DB)

Types

type Error

type Error struct {
	Resource interface{}
	Column   string
	Message  string
}

Error is a validation error struct that hold model, column and error message

func (Error) Error

func (err Error) Error() string

Error show error message

func (Error) Label

func (err Error) Label() string

Label is a label including model type, primary key and column name

type ValidationFailed

type ValidationFailed struct {
	Resource  interface{}
	Column    string
	FieldName string
	Message   string
	Path      string
}

Error is a validation error struct that hold model, column and error message

func (ValidationFailed) Error

func (err ValidationFailed) Error() string

Error show error message

func (ValidationFailed) Label

func (err ValidationFailed) Label() string

Label is a label including model type, primary key and column name

Jump to

Keyboard shortcuts

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