shared

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 7 Imported by: 52

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 added in v0.5.0

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 added in v0.5.0

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 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

	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) Key

func (ctx RuleContext) Key(name, idx string) (out RuleContext, err 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