funcs

package
v0.0.0-...-fc59d6d Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExtraPkg = map[string]string{}

map[pkgPath]pkgName

View Source
var ExtraPkgPath = map[string]string{}
View Source
var FuncMap = map[string]interface{}{

	"required":  RequiredOneOf,
	"has":       Has,
	"needs":     Needs,
	"fileneeds": FileNeeds,
	"isEnum":    isEnum,
	"enumList":  enumList,
	"enumVal":   enumVal,

	"byteStr":       byteStr,
	"cmt":           C80,
	"durGt":         durGt,
	"durLit":        durLit,
	"durStr":        durStr,
	"err":           err,
	"errCause":      errCause,
	"errIdx":        errIdx,
	"inKey":         inKey,
	"inType":        inType,
	"isBytes":       isBytes,
	"lit":           lit,
	"lookup":        lookup,
	"oneOfType":     oneOfTypeName,
	"tsGt":          tsGt,
	"tsLit":         tsLit,
	"tsStr":         tsStr,
	"externalEnums": externalEnums,
	"enumName":      EnumName,

	"OnType":      OnType,
	"GetElemRule": GetElemRule,
	"inKind":      inKind,
}
View Source
var StdPkg = map[string]int{
	"bytes":   0,
	"errors":  0,
	"fmt":     0,
	"net":     0,
	"mail":    0,
	"url":     0,
	"regexp":  0,
	"sort":    0,
	"strings": 0,
	"time":    0,
	"utf8":    0,
	"anypb":   0,
}

Functions

func C

func C(wrap int, args ...interface{}) string

C returns a comment block, wrapping when the line's length will exceed wrap.

func C80

func C80(args ...interface{}) string

C80 is an alias for C(80, args...)

func Disabled

func Disabled(msg protogen.Message) (disabled bool)

Disabled returns true if validations are disabled for msg

func EnumName

func EnumName(enum protoreflect.EnumDescriptor) string

func FileNeeds

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

func GetElemRule

func GetElemRule(field protogen.Field, rule proto.Message) (rules *v.FieldRules, err error)

func GetImports

func GetImports(fileDesc protoreflect.FileDescriptor) map[string]string

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 protogen.Message) (ignored bool)

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

func Needs

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

func OnType

func OnType(field *protogen.Field, typ string) string

func Render

func Render(tpl *template.Template) func(tmplName string, data interface{}) (string, error)

func RequiredOneOf

func RequiredOneOf(oo protogen.Oneof) (required bool)

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

Types

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