examples

package
v0.20231001.10 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Code generated by protoc-gen-go-cybozu-validate. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	Enums_Enum_name = map[int32]string{
		0:   "E_UNSPECIFIED",
		1:   "E_VAL1",
		100: "E_VAL100",
	}
	Enums_Enum_value = map[string]int32{
		"E_UNSPECIFIED": 0,
		"E_VAL1":        1,
		"E_VAL100":      100,
	}
)

Enum value maps for Enums_Enum.

View Source
var File_examples_validation_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Composed

type Composed struct {

	// enforces that `ignored` is set.
	Ignored *Ignored `protobuf:"bytes,1,opt,name=ignored,proto3" json:"ignored,omitempty"`
	Scalars *Scalars `protobuf:"bytes,2,opt,name=scalars,proto3" json:"scalars,omitempty"`
	Maps    []*Maps  `protobuf:"bytes,3,rep,name=maps,proto3" json:"maps,omitempty"`
	// enforces that all messages in `enums` are set.
	Enums []*Enums `protobuf:"bytes,4,rep,name=enums,proto3" json:"enums,omitempty"`
	// contains filtered or unexported fields
}

message type fields are normalized/validated recursively.

func (*Composed) Descriptor deprecated

func (*Composed) Descriptor() ([]byte, []int)

Deprecated: Use Composed.ProtoReflect.Descriptor instead.

func (*Composed) GetEnums

func (x *Composed) GetEnums() []*Enums

func (*Composed) GetIgnored

func (x *Composed) GetIgnored() *Ignored

func (*Composed) GetMaps

func (x *Composed) GetMaps() []*Maps

func (*Composed) GetScalars

func (x *Composed) GetScalars() *Scalars

func (*Composed) ProtoMessage

func (*Composed) ProtoMessage()

func (*Composed) ProtoReflect

func (x *Composed) ProtoReflect() protoreflect.Message

func (*Composed) Reset

func (x *Composed) Reset()

func (*Composed) String

func (x *Composed) String() string

func (*Composed) Validate

func (x *Composed) Validate() error

type Enums

type Enums struct {

	// enforces that `e1` is not the zero value.
	E1 Enums_Enum `protobuf:"varint,1,opt,name=e1,proto3,enum=examples.Enums_Enum" json:"e1,omitempty"`
	// enforces that `e2` is one of the defined enum value.
	E2 Enums_Enum `protobuf:"varint,2,opt,name=e2,proto3,enum=examples.Enums_Enum" json:"e2,omitempty"`
	// enforces that `e3` is one of the defined enum value other than zero.
	E3 []Enums_Enum `protobuf:"varint,3,rep,packed,name=e3,proto3,enum=examples.Enums_Enum" json:"e3,omitempty"`
	// enforces that `e4` is, if given, one of the defined enum value other than zero.
	E4 *Enums_Enum `protobuf:"varint,4,opt,name=e4,proto3,enum=examples.Enums_Enum,oneof" json:"e4,omitempty"`
	// contains filtered or unexported fields
}

func (*Enums) Descriptor deprecated

func (*Enums) Descriptor() ([]byte, []int)

Deprecated: Use Enums.ProtoReflect.Descriptor instead.

func (*Enums) GetE1

func (x *Enums) GetE1() Enums_Enum

func (*Enums) GetE2

func (x *Enums) GetE2() Enums_Enum

func (*Enums) GetE3

func (x *Enums) GetE3() []Enums_Enum

func (*Enums) GetE4

func (x *Enums) GetE4() Enums_Enum

func (*Enums) ProtoMessage

func (*Enums) ProtoMessage()

func (*Enums) ProtoReflect

func (x *Enums) ProtoReflect() protoreflect.Message

func (*Enums) Reset

func (x *Enums) Reset()

func (*Enums) String

func (x *Enums) String() string

func (*Enums) Validate

func (x *Enums) Validate() error

type Enums_Enum

type Enums_Enum int32
const (
	Enums_E_UNSPECIFIED Enums_Enum = 0
	Enums_E_VAL1        Enums_Enum = 1
	Enums_E_VAL100      Enums_Enum = 100
)

func (Enums_Enum) Descriptor

func (Enums_Enum) Descriptor() protoreflect.EnumDescriptor

func (Enums_Enum) Enum

func (x Enums_Enum) Enum() *Enums_Enum

func (Enums_Enum) EnumDescriptor deprecated

func (Enums_Enum) EnumDescriptor() ([]byte, []int)

Deprecated: Use Enums_Enum.Descriptor instead.

func (Enums_Enum) Number

func (x Enums_Enum) Number() protoreflect.EnumNumber

func (Enums_Enum) String

func (x Enums_Enum) String() string

func (Enums_Enum) Type

type Ignored

type Ignored struct {
	Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"`
	Bar int32  `protobuf:"varint,2,opt,name=bar,proto3" json:"bar,omitempty"` // no effect
	// contains filtered or unexported fields
}

This message is marked ignored, so no validation method is generated.

func (*Ignored) Descriptor deprecated

func (*Ignored) Descriptor() ([]byte, []int)

Deprecated: Use Ignored.ProtoReflect.Descriptor instead.

func (*Ignored) GetBar

func (x *Ignored) GetBar() int32

func (*Ignored) GetFoo

func (x *Ignored) GetFoo() string

func (*Ignored) ProtoMessage

func (*Ignored) ProtoMessage()

func (*Ignored) ProtoReflect

func (x *Ignored) ProtoReflect() protoreflect.Message

func (*Ignored) Reset

func (x *Ignored) Reset()

func (*Ignored) String

func (x *Ignored) String() string

type Maps

type Maps struct {

	// you can put a constraint for map and a constraint for the value type as follows.
	Map1 map[string]int32 `` /* 150-byte string literal not displayed */
	// or either one of them. The following enforces that the timestamp is set.
	Map2 map[string]*timestamppb.Timestamp `` /* 149-byte string literal not displayed */
	// string values are normalized into the NFC form even if there's no rules specified.
	Map3 map[uint32]string `` /* 150-byte string literal not displayed */
	// if the map key is a string, it is normalized into the NFC.
	// if the map vakue is a message, fields in it are always normalized/validated.
	Map4 map[string]*Scalars `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

In addition to the validation code generated from the protobuf options, this message implements a custom validation. See `example_custom.go` in the same directory.

func (*Maps) Descriptor deprecated

func (*Maps) Descriptor() ([]byte, []int)

Deprecated: Use Maps.ProtoReflect.Descriptor instead.

func (*Maps) GetMap1

func (x *Maps) GetMap1() map[string]int32

func (*Maps) GetMap2

func (x *Maps) GetMap2() map[string]*timestamppb.Timestamp

func (*Maps) GetMap3

func (x *Maps) GetMap3() map[uint32]string

func (*Maps) GetMap4

func (x *Maps) GetMap4() map[string]*Scalars

func (*Maps) ProtoMessage

func (*Maps) ProtoMessage()

func (*Maps) ProtoReflect

func (x *Maps) ProtoReflect() protoreflect.Message

func (*Maps) Reset

func (x *Maps) Reset()

func (*Maps) String

func (x *Maps) String() string

func (*Maps) Validate

func (x *Maps) Validate() error

func (*Maps) ValidateCustom

func (x *Maps) ValidateCustom() error

ValidateCustom is a hand-written additional validation for Maps. You can do any validation/normalization here.

This example checks that the total number of items in all map fields is not over 10.

type Nested added in v0.20230310.2

type Nested struct {
	Inner *Nested_Inner `protobuf:"bytes,1,opt,name=inner,proto3" json:"inner,omitempty"`
	// contains filtered or unexported fields
}

func (*Nested) Descriptor deprecated added in v0.20230310.2

func (*Nested) Descriptor() ([]byte, []int)

Deprecated: Use Nested.ProtoReflect.Descriptor instead.

func (*Nested) GetInner added in v0.20230310.2

func (x *Nested) GetInner() *Nested_Inner

func (*Nested) ProtoMessage added in v0.20230310.2

func (*Nested) ProtoMessage()

func (*Nested) ProtoReflect added in v0.20230310.2

func (x *Nested) ProtoReflect() protoreflect.Message

func (*Nested) Reset added in v0.20230310.2

func (x *Nested) Reset()

func (*Nested) String added in v0.20230310.2

func (x *Nested) String() string

func (*Nested) Validate added in v0.20230310.2

func (x *Nested) Validate() error

type Nested_Inner added in v0.20230310.2

type Nested_Inner struct {
	Int32 int32 `protobuf:"varint,1,opt,name=int32,proto3" json:"int32,omitempty"`
	// contains filtered or unexported fields
}

Inner will also be validated.

func (*Nested_Inner) Descriptor deprecated added in v0.20230310.2

func (*Nested_Inner) Descriptor() ([]byte, []int)

Deprecated: Use Nested_Inner.ProtoReflect.Descriptor instead.

func (*Nested_Inner) GetInt32 added in v0.20230310.2

func (x *Nested_Inner) GetInt32() int32

func (*Nested_Inner) ProtoMessage added in v0.20230310.2

func (*Nested_Inner) ProtoMessage()

func (*Nested_Inner) ProtoReflect added in v0.20230310.2

func (x *Nested_Inner) ProtoReflect() protoreflect.Message

func (*Nested_Inner) Reset added in v0.20230310.2

func (x *Nested_Inner) Reset()

func (*Nested_Inner) String added in v0.20230310.2

func (x *Nested_Inner) String() string

func (*Nested_Inner) Validate added in v0.20230310.2

func (x *Nested_Inner) Validate() error

type Oneofs

type Oneofs struct {

	// Types that are assignable to O1:
	//
	//	*Oneofs_Int32
	//	*Oneofs_String_
	O1 isOneofs_O1 `protobuf_oneof:"o1"`
	// Types that are assignable to O2:
	//
	//	*Oneofs_Ts
	//	*Oneofs_Bool
	O2 isOneofs_O2 `protobuf_oneof:"o2"`
	// contains filtered or unexported fields
}

func (*Oneofs) Descriptor deprecated

func (*Oneofs) Descriptor() ([]byte, []int)

Deprecated: Use Oneofs.ProtoReflect.Descriptor instead.

func (*Oneofs) GetBool

func (x *Oneofs) GetBool() bool

func (*Oneofs) GetInt32

func (x *Oneofs) GetInt32() int32

func (*Oneofs) GetO1

func (m *Oneofs) GetO1() isOneofs_O1

func (*Oneofs) GetO2

func (m *Oneofs) GetO2() isOneofs_O2

func (*Oneofs) GetString_

func (x *Oneofs) GetString_() string

func (*Oneofs) GetTs

func (x *Oneofs) GetTs() *timestamppb.Timestamp

func (*Oneofs) ProtoMessage

func (*Oneofs) ProtoMessage()

func (*Oneofs) ProtoReflect

func (x *Oneofs) ProtoReflect() protoreflect.Message

func (*Oneofs) Reset

func (x *Oneofs) Reset()

func (*Oneofs) String

func (x *Oneofs) String() string

func (*Oneofs) Validate

func (x *Oneofs) Validate() error

type Oneofs_Bool

type Oneofs_Bool struct {
	Bool bool `protobuf:"varint,4,opt,name=bool,proto3,oneof"`
}

type Oneofs_Int32

type Oneofs_Int32 struct {
	Int32 int32 `protobuf:"varint,1,opt,name=int32,proto3,oneof"`
}

type Oneofs_String_

type Oneofs_String_ struct {
	String_ string `protobuf:"bytes,2,opt,name=string,proto3,oneof"`
}

type Oneofs_Ts

type Oneofs_Ts struct {
	Ts *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=ts,proto3,oneof"`
}

type OptionalScalars

type OptionalScalars struct {
	Float    *float32 `protobuf:"fixed32,1,opt,name=float,proto3,oneof" json:"float,omitempty"`
	Double   *float64 `protobuf:"fixed64,2,opt,name=double,proto3,oneof" json:"double,omitempty"`
	Int32    *int32   `protobuf:"varint,3,opt,name=int32,proto3,oneof" json:"int32,omitempty"`
	Int64    *int64   `protobuf:"varint,4,opt,name=int64,proto3,oneof" json:"int64,omitempty"`
	Uint32   *uint32  `protobuf:"varint,5,opt,name=uint32,proto3,oneof" json:"uint32,omitempty"`
	Uint64   *uint64  `protobuf:"varint,6,opt,name=uint64,proto3,oneof" json:"uint64,omitempty"`
	Sint32   *int32   `protobuf:"zigzag32,7,opt,name=sint32,proto3,oneof" json:"sint32,omitempty"`
	Sint64   *int64   `protobuf:"zigzag64,8,opt,name=sint64,proto3,oneof" json:"sint64,omitempty"`
	Fixed32  *uint32  `protobuf:"fixed32,9,opt,name=fixed32,proto3,oneof" json:"fixed32,omitempty"`
	Fixed64  *uint64  `protobuf:"fixed64,10,opt,name=fixed64,proto3,oneof" json:"fixed64,omitempty"`
	Sfixed32 *int32   `protobuf:"fixed32,11,opt,name=sfixed32,proto3,oneof" json:"sfixed32,omitempty"`
	Sfixed64 *int64   `protobuf:"fixed64,12,opt,name=sfixed64,proto3,oneof" json:"sfixed64,omitempty"`
	Bool     *bool    `protobuf:"varint,13,opt,name=bool,proto3,oneof" json:"bool,omitempty"` // no available rules for bool
	String_  *string  `protobuf:"bytes,14,opt,name=string,proto3,oneof" json:"string,omitempty"`
	Bytes    []byte   `protobuf:"bytes,15,opt,name=bytes,proto3,oneof" json:"bytes,omitempty"`
	// contains filtered or unexported fields
}

rules for optional fields are enforced only if the field is set.

func (*OptionalScalars) Descriptor deprecated

func (*OptionalScalars) Descriptor() ([]byte, []int)

Deprecated: Use OptionalScalars.ProtoReflect.Descriptor instead.

func (*OptionalScalars) GetBool

func (x *OptionalScalars) GetBool() bool

func (*OptionalScalars) GetBytes

func (x *OptionalScalars) GetBytes() []byte

func (*OptionalScalars) GetDouble

func (x *OptionalScalars) GetDouble() float64

func (*OptionalScalars) GetFixed32

func (x *OptionalScalars) GetFixed32() uint32

func (*OptionalScalars) GetFixed64

func (x *OptionalScalars) GetFixed64() uint64

func (*OptionalScalars) GetFloat

func (x *OptionalScalars) GetFloat() float32

func (*OptionalScalars) GetInt32

func (x *OptionalScalars) GetInt32() int32

func (*OptionalScalars) GetInt64

func (x *OptionalScalars) GetInt64() int64

func (*OptionalScalars) GetSfixed32

func (x *OptionalScalars) GetSfixed32() int32

func (*OptionalScalars) GetSfixed64

func (x *OptionalScalars) GetSfixed64() int64

func (*OptionalScalars) GetSint32

func (x *OptionalScalars) GetSint32() int32

func (*OptionalScalars) GetSint64

func (x *OptionalScalars) GetSint64() int64

func (*OptionalScalars) GetString_

func (x *OptionalScalars) GetString_() string

func (*OptionalScalars) GetUint32

func (x *OptionalScalars) GetUint32() uint32

func (*OptionalScalars) GetUint64

func (x *OptionalScalars) GetUint64() uint64

func (*OptionalScalars) ProtoMessage

func (*OptionalScalars) ProtoMessage()

func (*OptionalScalars) ProtoReflect

func (x *OptionalScalars) ProtoReflect() protoreflect.Message

func (*OptionalScalars) Reset

func (x *OptionalScalars) Reset()

func (*OptionalScalars) String

func (x *OptionalScalars) String() string

func (*OptionalScalars) Validate

func (x *OptionalScalars) Validate() error

type RepeatedScalars

type RepeatedScalars struct {

	// a repeated field can specify `repeated` constraints like this
	Float []float32 `protobuf:"fixed32,1,rep,packed,name=float,proto3" json:"float,omitempty"`
	// or this
	Double []float64 `protobuf:"fixed64,2,rep,packed,name=double,proto3" json:"double,omitempty"`
	// or this.
	String_ []string `protobuf:"bytes,3,rep,name=string,proto3" json:"string,omitempty"`
	// contains filtered or unexported fields
}

func (*RepeatedScalars) Descriptor deprecated

func (*RepeatedScalars) Descriptor() ([]byte, []int)

Deprecated: Use RepeatedScalars.ProtoReflect.Descriptor instead.

func (*RepeatedScalars) GetDouble

func (x *RepeatedScalars) GetDouble() []float64

func (*RepeatedScalars) GetFloat

func (x *RepeatedScalars) GetFloat() []float32

func (*RepeatedScalars) GetString_

func (x *RepeatedScalars) GetString_() []string

func (*RepeatedScalars) ProtoMessage

func (*RepeatedScalars) ProtoMessage()

func (*RepeatedScalars) ProtoReflect

func (x *RepeatedScalars) ProtoReflect() protoreflect.Message

func (*RepeatedScalars) Reset

func (x *RepeatedScalars) Reset()

func (*RepeatedScalars) String

func (x *RepeatedScalars) String() string

func (*RepeatedScalars) Validate

func (x *RepeatedScalars) Validate() error

type Scalars

type Scalars struct {
	Float    float32 `protobuf:"fixed32,1,opt,name=float,proto3" json:"float,omitempty"`
	Double   float64 `protobuf:"fixed64,2,opt,name=double,proto3" json:"double,omitempty"`
	Int32    int32   `protobuf:"varint,3,opt,name=int32,proto3" json:"int32,omitempty"`
	Int64    int64   `protobuf:"varint,4,opt,name=int64,proto3" json:"int64,omitempty"`
	Uint32   uint32  `protobuf:"varint,5,opt,name=uint32,proto3" json:"uint32,omitempty"`
	Uint64   uint64  `protobuf:"varint,6,opt,name=uint64,proto3" json:"uint64,omitempty"`
	Sint32   int32   `protobuf:"zigzag32,7,opt,name=sint32,proto3" json:"sint32,omitempty"`
	Sint64   int64   `protobuf:"zigzag64,8,opt,name=sint64,proto3" json:"sint64,omitempty"`
	Fixed32  uint32  `protobuf:"fixed32,9,opt,name=fixed32,proto3" json:"fixed32,omitempty"`
	Fixed64  uint64  `protobuf:"fixed64,10,opt,name=fixed64,proto3" json:"fixed64,omitempty"`
	Sfixed32 int32   `protobuf:"fixed32,11,opt,name=sfixed32,proto3" json:"sfixed32,omitempty"`
	Sfixed64 int64   `protobuf:"fixed64,12,opt,name=sfixed64,proto3" json:"sfixed64,omitempty"`
	Bool     bool    `protobuf:"varint,13,opt,name=bool,proto3" json:"bool,omitempty"` // no available rules for bools
	String_  string  `protobuf:"bytes,14,opt,name=string,proto3" json:"string,omitempty"`
	Bytes    []byte  `protobuf:"bytes,15,opt,name=bytes,proto3" json:"bytes,omitempty"`
	// contains filtered or unexported fields
}

All scalar types can have constraint rules except for bools.

func (*Scalars) Descriptor deprecated

func (*Scalars) Descriptor() ([]byte, []int)

Deprecated: Use Scalars.ProtoReflect.Descriptor instead.

func (*Scalars) GetBool

func (x *Scalars) GetBool() bool

func (*Scalars) GetBytes

func (x *Scalars) GetBytes() []byte

func (*Scalars) GetDouble

func (x *Scalars) GetDouble() float64

func (*Scalars) GetFixed32

func (x *Scalars) GetFixed32() uint32

func (*Scalars) GetFixed64

func (x *Scalars) GetFixed64() uint64

func (*Scalars) GetFloat

func (x *Scalars) GetFloat() float32

func (*Scalars) GetInt32

func (x *Scalars) GetInt32() int32

func (*Scalars) GetInt64

func (x *Scalars) GetInt64() int64

func (*Scalars) GetSfixed32

func (x *Scalars) GetSfixed32() int32

func (*Scalars) GetSfixed64

func (x *Scalars) GetSfixed64() int64

func (*Scalars) GetSint32

func (x *Scalars) GetSint32() int32

func (*Scalars) GetSint64

func (x *Scalars) GetSint64() int64

func (*Scalars) GetString_

func (x *Scalars) GetString_() string

func (*Scalars) GetUint32

func (x *Scalars) GetUint32() uint32

func (*Scalars) GetUint64

func (x *Scalars) GetUint64() uint64

func (*Scalars) ProtoMessage

func (*Scalars) ProtoMessage()

func (*Scalars) ProtoReflect

func (x *Scalars) ProtoReflect() protoreflect.Message

func (*Scalars) Reset

func (x *Scalars) Reset()

func (*Scalars) String

func (x *Scalars) String() string

func (*Scalars) Validate

func (x *Scalars) Validate() error

type Strings

type Strings struct {

	// NFC normalization is applied if no options are given.
	S1 string `protobuf:"bytes,1,opt,name=s1,proto3" json:"s1,omitempty"`
	// normalize into the NFD form.
	S2 string `protobuf:"bytes,2,opt,name=s2,proto3" json:"s2,omitempty"`
	// enforce the minimum length of the string if the string is NOT empty.
	// This check is done after NFC normalization.
	S3 string `protobuf:"bytes,3,opt,name=s3,proto3" json:"s3,omitempty"`
	// normalize and validate the string with a PRECIS profile.
	S4 string `protobuf:"bytes,4,opt,name=s4,proto3" json:"s4,omitempty"`
	// normalize and validate the string with a PRECIS profile.
	S5 string `protobuf:"bytes,5,opt,name=s5,proto3" json:"s5,omitempty"`
	// normalize and validate the string with a PRECIS profile.
	S6 string `protobuf:"bytes,6,opt,name=s6,proto3" json:"s6,omitempty"`
	// enforce that the string matches a regular expresson. The regular expression syntax is RE2.
	// See https://github.com/google/re2/wiki/Syntax
	S7 string `protobuf:"bytes,7,opt,name=s7,proto3" json:"s7,omitempty"`
	// enforce that the string is a valid email address as defined in RFC 5322.
	S8 string `protobuf:"bytes,8,opt,name=s8,proto3" json:"s8,omitempty"`
	// enforce that the string is a valid URI as defined in RFC 3986.
	// The string will also be canonicalized.
	S9 string `protobuf:"bytes,9,opt,name=s9,proto3" json:"s9,omitempty"`
	// enforce that the string is a valid telephone number as defined by E.164.
	// An example is "+81-80-0000-0000".
	S10 string `protobuf:"bytes,10,opt,name=s10,proto3" json:"s10,omitempty"`
	// contains filtered or unexported fields
}

Strings have the richest set of constraint rules.

func (*Strings) Descriptor deprecated

func (*Strings) Descriptor() ([]byte, []int)

Deprecated: Use Strings.ProtoReflect.Descriptor instead.

func (*Strings) GetS1

func (x *Strings) GetS1() string

func (*Strings) GetS10

func (x *Strings) GetS10() string

func (*Strings) GetS2

func (x *Strings) GetS2() string

func (*Strings) GetS3

func (x *Strings) GetS3() string

func (*Strings) GetS4

func (x *Strings) GetS4() string

func (*Strings) GetS5

func (x *Strings) GetS5() string

func (*Strings) GetS6

func (x *Strings) GetS6() string

func (*Strings) GetS7

func (x *Strings) GetS7() string

func (*Strings) GetS8

func (x *Strings) GetS8() string

func (*Strings) GetS9

func (x *Strings) GetS9() string

func (*Strings) ProtoMessage

func (*Strings) ProtoMessage()

func (*Strings) ProtoReflect

func (x *Strings) ProtoReflect() protoreflect.Message

func (*Strings) Reset

func (x *Strings) Reset()

func (*Strings) String

func (x *Strings) String() string

func (*Strings) Validate

func (x *Strings) Validate() error

Jump to

Keyboard shortcuts

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