validation

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldType     = "type"
	FieldChannels = "channels"
	FieldToken    = "token"
)

Variables

This section is empty.

Functions

func SubField

func SubField(field string, child string) string

SubField creates a field that includes parent and child that separated by a default separator.

Types

type Result

type Result struct {
	Error       string       `json:"error,omitempty"`
	Code        string       `json:"code,omitempty"`
	FieldErrors []fieldError `json:"field_errors,omitempty"`
}

Result represent validation result that include error message, error code, and field validation errors.

func NewResult

func NewResult(code, err string) *Result

NewResult creates a new Result object with the input code and error.

func (*Result) AddFieldError

func (r *Result) AddFieldError(field string, err string)

AddFieldError creates a new fieldError object and adds it to the Result.FieldErrors

func (Result) IsValid

func (r Result) IsValid() bool

IsValid returns false if there is error, code, or field errors does exist. Otherwise, returns true.

type Validator

type Validator interface {
	Validate() *Result
}

Jump to

Keyboard shortcuts

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