shared

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 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 Has

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

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

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)

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

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

Jump to

Keyboard shortcuts

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