validator

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "thrift-gen-kitex"

PluginName is the link name when the kitex binary is used as a plugin for thriftgo.

View Source
const TheUseOptionMessage = "kitex_gen is not generated due to the -use option"

TheUseOptionMessage indicates that the generating of kitex_gen is aborted due to the -use option.

View Source
const (
	Version = "v0.2.5"
)

Variables

View Source
var FieldValidate = `` /* 299-byte string literal not displayed */

FieldValidate .

View Source
var FieldValidateBase = `` /* 647-byte string literal not displayed */

FieldValidateBase .

View Source
var FieldValidateContainer = `` /* 445-byte string literal not displayed */

FieldValidateContainer .

View Source
var FieldValidateList = `` /* 330-byte string literal not displayed */

FieldValidateList .

View Source
var FieldValidateMap = `` /* 325-byte string literal not displayed */

FieldValidateMap .

View Source
var FieldValidateSet = `` /* 328-byte string literal not displayed */

FieldValidateSet .

View Source
var FieldValidateStructLike = `
{{define "FieldValidateStructLike"}}
	{{- rule := range .Rules}}
	{{- if eq .Annotation $StructLikeAnnotation.Skip}}
	
	{{- else if eq . Annotation $StructLikeAnnotation.NotNil}}
	{{- end}}
	if !{{.Target}}.` + ValidMethodName + `({{.Source}}) {
		return false
	}
{{- end}}{{/* "FieldValidateStructLike" */}}
`

FieldValidateStructLike .

View Source
var StructLikeValidate = `
{{define "StructLikeValidate"}}
{{- $TypeName := .Name | Identify}}
func (p *{{$TypeName}}) ` + ValidMethodName + `() bool {
	{{- ctxs := MkValidateContexts .Fields}}
	{{- range .ctxs}}
	{{template "FieldValidate" .}}
	{{- end}}{{/* range .ctxs */}}
	return true
}
{{- end}}{{/* "StructLikeValidate" */}}
`

StructLikeValidate .

View Source
var ValidMethodName string = "IsValid"

Functions

func HandleRequest added in v0.2.4

func HandleRequest(req *plugin.Request) *plugin.Response

func Run

func Run() int

Run is an entry of the plugin mode of kitex for thriftgo. It reads a plugin request from the standard input and writes out a response.

Types

type ValidateContext

type ValidateContext struct {
	AST          *tp.Thrift
	FieldName    string
	RawFieldName string
	Resolver     *golang.Resolver
	StructLike   *golang.StructLike
	*golang.ReadWriteContext
	*parser.Validation
	IsOptional bool
	// contains filtered or unexported fields
}

func (*ValidateContext) GenID

func (v *ValidateContext) GenID(prefix string) (name string)

type ValidatorSDKPlugin added in v0.2.4

type ValidatorSDKPlugin struct {
	PluginParameters []string
}

func NewValidatorSDKPlugin added in v0.2.4

func NewValidatorSDKPlugin(params string) *ValidatorSDKPlugin

func (*ValidatorSDKPlugin) GetName added in v0.2.4

func (k *ValidatorSDKPlugin) GetName() string

func (*ValidatorSDKPlugin) GetPluginParameters added in v0.2.4

func (k *ValidatorSDKPlugin) GetPluginParameters() []string

func (*ValidatorSDKPlugin) Invoke added in v0.2.4

func (k *ValidatorSDKPlugin) Invoke(req *plugin.Request) (res *plugin.Response)

Jump to

Keyboard shortcuts

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