validate

package
v0.0.0-...-2ef61a0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package validate wraps an immediate validtor to validate a struct or a variate using comment tags.

Usage:

err := Validator().Struct(...)
if err != nil {
    // handle error ...
}
// ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validate

type Validate interface {
	Struct(s interface{}) error
	StructCtx(ctx context.Context, s interface{}) error
	Var(field interface{}, tag string) error
	VarCtx(ctx context.Context, field interface{}, tag string) error
}

Validate is a default interface for validating data.

func IsValidate

func IsValidate(wrapped WrappedValidator) (Validate, bool)

IsValidate used to switch to Validate interface.

func Validator

func Validator() Validate

Validator return the default package validator.

type WrappedValidator

type WrappedValidator interface {
	Engine() Validate
	UniversalTranslator() interface{}
}

WrappedValidator is a default interface for approaching the internal instances.

func IsWrapped

func IsWrapped(vali Validate) (WrappedValidator, bool)

IsWrapped used to switch to WrappedValidator interface, used to get the internal instance.

Jump to

Keyboard shortcuts

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