protopreparsevalidation

package
v0.0.0-...-c101335 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RepeatedFieldLimitError

type RepeatedFieldLimitError struct {
	Path  string
	Count int
	Limit int
}

func (*RepeatedFieldLimitError) Error

func (e *RepeatedFieldLimitError) Error() string

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func Compile

func Compile(root protoreflect.MessageDescriptor, fieldLimits map[protoreflect.FullName]int) (*Validator, error)

The returned Validator is stateful and must not be used concurrently.

Assumptions and Limitations:

  • No recursive schemas: the compiler rejects cyclic message descriptor graphs.
  • No map fields: map fields are rejected at compile time because their wire representation (repeated synthetic entry messages) would require special handling, and we don't use them in our schemas.
  • No repeated packable scalars (except bool): packed encoding merges multiple values into a single length-delimited record, making wire-level element counting inaccurate. Rather than adding complexity, we forbid these field types.
  • No field numbers above maxAllowedFieldNumber to keep memory footprint small.
  • See also the comment on Validator.

func (*Validator) Validate

func (validator *Validator) Validate(message []byte) error

Validate scans each message slice once, enforcing repeated-field limits and recursively validating bounded nested message subtrees before full unmarshal.

Jump to

Keyboard shortcuts

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