validator

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 16 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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