shared

package
v0.0.0-...-fa4fb7d Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Disabled

func Disabled(msg pgs.Message) (disabled bool, err error)

Disabled returns true if validations are disabled for msg

func FileNeeds

func FileNeeds(f pgs.File, wk WellKnown) bool

func Has

func Has(msg proto.Message, fld string) bool

Has returns true if the provided Message has the a field fld.

func Ignored

func Ignored(msg pgs.Message) (ignored bool, err error)

Ignore returns true if validations aren't to be generated for msg

func Needs

func Needs(m pgs.Message, wk WellKnown) bool

Needs returns true if a well-known string validator is needed for this message.

func OneOfRule

func OneOfRule(oo pgs.OneOf) (rule *validate.OneOf, err error)

OneOfRule returns oneof rule

func RegisterFunctions

func RegisterFunctions(tpl *template.Template, params pgs.Parameters)

func Render

func Render(tpl *template.Template) func(ctx RuleContext) (string, error)

func RequiredOneOf

func RequiredOneOf(oo pgs.OneOf) (required bool, err error)

RequiredOneOf returns true if the oneof field requires a field to be set

Types

type RuleContext

type RuleContext struct {
	Field        pgs.Field
	Rules        proto.Message
	MessageRules *validate.MessageRules
	DefineErr    bool
	ErrBase      *validate.ErrorBase
	ErrIndex     int

	Typ        string
	WrapperTyp string

	OnKey            bool
	Index            string
	AccessorOverride string
}

func (RuleContext) Elem

func (ctx RuleContext) Elem(name, idx string) (out RuleContext, err error)

func (RuleContext) ElemWithErrIndex

func (ctx RuleContext) ElemWithErrIndex(name, idx string, errIndex int) (RuleContext, error)

func (RuleContext) Key

func (ctx RuleContext) Key(name, idx string) (out RuleContext, err error)

func (RuleContext) KeyWithErrIndex

func (ctx RuleContext) KeyWithErrIndex(name, idx string, errIndex int) (RuleContext, error)

func (RuleContext) Unwrap

func (ctx RuleContext) Unwrap(name string) (out RuleContext, err error)

type WellKnown

type WellKnown string
const (
	Email    WellKnown = "email"
	Hostname WellKnown = "hostname"
	UUID     WellKnown = "uuid"
)

Jump to

Keyboard shortcuts

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