shared

package
v2.0.0-...-f76f62a Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 13 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 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 Register

func Register(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 Func

type Func struct {
	pgsgo.Context
}

func (Func) Accessor

func (fn Func) Accessor(ctx RuleContext) string

func (Func) ByteStr

func (fn Func) ByteStr(x []byte) string

func (Func) DurationGt

func (fn Func) DurationGt(a, b *durationpb.Duration) bool

func (Func) DurationLit

func (fn Func) DurationLit(dur *durationpb.Duration) string

func (Func) DurationStr

func (fn Func) DurationStr(dur *durationpb.Duration) string

func (Func) EnumPackages

func (fn Func) EnumPackages(enums []pgs.Enum) map[pgs.FilePath]pgs.Name

func (Func) Error

func (fn Func) Error(ctx RuleContext, reason ...interface{}) string

func (Func) ErrorCause

func (fn Func) ErrorCause(ctx RuleContext, cause string, reason ...interface{}) string

func (Func) ErrorIdx

func (fn Func) ErrorIdx(ctx RuleContext, idx string, reason ...interface{}) string

func (Func) ErrorIdxCause

func (fn Func) ErrorIdxCause(ctx RuleContext, idx, cause string, reason ...interface{}) string

func (Func) ErrorName

func (fn Func) ErrorName(m pgs.Message) pgs.Name

func (Func) ExternalEnums

func (fn Func) ExternalEnums(file pgs.File) []pgs.Enum

func (Func) InKey

func (fn Func) InKey(f pgs.Field, x interface{}) string

func (Func) InType

func (fn Func) InType(f pgs.Field, x interface{}) string

func (Func) IsBytes

func (fn Func) IsBytes(f interface {
	ProtoType() pgs.ProtoType
}) bool

func (Func) Lit

func (fn Func) Lit(x interface{}) string

func (Func) Lookup

func (fn Func) Lookup(f pgs.Field, name string) string

func (Func) MessageType

func (fn Func) MessageType(message pgs.Message) pgsgo.TypeName

func (Func) OneOfTypeName

func (fn Func) OneOfTypeName(f pgs.Field) pgsgo.TypeName

func (Func) Optional

func (fn Func) Optional(f pgs.Field) bool

func (Func) SnakeCase

func (fn Func) SnakeCase(name string) string

func (Func) TimestampGt

func (fn Func) TimestampGt(a, b *timestamppb.Timestamp) bool

func (Func) TimestampLit

func (fn Func) TimestampLit(ts *timestamppb.Timestamp) string

func (Func) TimestampStr

func (fn Func) TimestampStr(ts *timestamppb.Timestamp) string

func (Func) Unwrap

func (fn Func) Unwrap(ctx RuleContext, name string) (RuleContext, error)

type RuleContext

type RuleContext struct {
	Field        pgs.Field
	Rules        proto.Message
	MessageRules *validate.MessageRules

	Typ         string
	WrapperTyp  string
	CustomError string

	OnKey            bool
	Index            string
	AccessorOverride string
}

func RulesContext

func RulesContext(f pgs.Field) (out RuleContext, err error)

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