validate

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidJSON = errors.New("invalid json")
)

Functions

func IsISO8601Date

func IsISO8601Date(fl validator.FieldLevel) bool

func IsNumber

func IsNumber(fl validator.FieldLevel) bool

func IsObject

func IsObject(fl validator.FieldLevel) bool

func Pattern

func Pattern(val string) *string

func RegisterCustomValidations added in v0.2.2

func RegisterCustomValidations(validator *validator.Validate)

Types

type FieldError

type FieldError struct {
	Field            string
	Rule             string
	Value            interface{}
	Accepted         string
	ValidationErrors validator.ValidationErrors
}

func (FieldError) Error

func (v FieldError) Error() string

type FieldPath

type FieldPath []string

func (*FieldPath) String

func (path *FieldPath) String() string

type FieldSchema

type FieldSchema struct {
	Type       string
	Name       string
	Value      interface{}
	Rule       Rule
	Rules      Rules
	Properties MapField
	Items      FieldsArray
}

func (*FieldSchema) IsRequired

func (f *FieldSchema) IsRequired() bool

func (*FieldSchema) UnmarshalJSON

func (f *FieldSchema) UnmarshalJSON(data []byte) error

type FieldsArray

type FieldsArray []MapField

func (FieldsArray) Get

func (f FieldsArray) Get(index int) *FieldSchema

type MapField

type MapField map[string]FieldSchema

func (MapField) Get

func (m MapField) Get(index string) FieldSchema

type Rule

type Rule struct {
	Path    FieldPath
	Rules   Rules
	Pattern *string
}

func (*Rule) Has

func (r *Rule) Has(name string) bool

type Rules

type Rules []string

func (Rules) ForBool

func (r Rules) ForBool() Rules

func (Rules) Required

func (r Rules) Required() bool

func (Rules) String

func (r Rules) String() string

type RulesMap

type RulesMap map[string]Rule

type SchemaValidator

type SchemaValidator struct {
	// contains filtered or unexported fields
}

func NewSchemaValidator

func NewSchemaValidator(v *validator.Validate, req *http.Request, ctx context.Context) (schemaValidator *SchemaValidator, err error)

func (*SchemaValidator) AddRule

func (s *SchemaValidator) AddRule(path string, rule string, pattern *string)

func (*SchemaValidator) GetRule

func (s *SchemaValidator) GetRule(path []string) *Rule

func (*SchemaValidator) HasRule

func (s *SchemaValidator) HasRule(path []string) bool

func (*SchemaValidator) Validate

func (s *SchemaValidator) Validate() error

type SliceField

type SliceField interface {
	Get(index string) interface{}
}

type TreeField

type TreeField struct {
	Field string
	Value interface{}
	Rule  Rules
}

type ValidationErrors

type ValidationErrors map[string][]FieldError

func (ValidationErrors) Error

func (vErrors ValidationErrors) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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