Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶ added in v1.74.0
type Checker struct {
// contains filtered or unexported fields
}
Checker checks protovalidate rules.
A Checker holds state that is reused across checks, so it should be created once per set of files being checked and then discarded.
func NewChecker ¶ added in v1.74.0
func NewChecker(extensionTypeResolver protoencoding.Resolver) (*Checker, error)
NewChecker returns a new Checker.
The extensionTypeResolver must be able to resolve every predefined rule extension used by the checked files, including those from imported files.
func (*Checker) CheckField ¶ added in v1.74.0
func (c *Checker) CheckField( addAnnotationFunc func(bufprotosource.Descriptor, bufprotosource.Location, []bufprotosource.Location, string, ...any), field bufprotosource.Field, ) error
CheckField validates that all rules on the field are valid, and any CEL expressions compile.
For a set of rules to be valid, it must
- permit _some_ value and all example values, if any
- have a type compatible with the field it validates.
func (*Checker) CheckMessage ¶ added in v1.74.0
func (c *Checker) CheckMessage( addAnnotationFunc func(bufprotosource.Descriptor, bufprotosource.Location, []bufprotosource.Location, string, ...any), message bufprotosource.Message, ) error
CheckMessage validates that all rules on the message are valid, and any CEL expressions compile. It also checks all predefined rule extensions on the messages.
func (*Checker) CheckPredefinedRuleExtension ¶ added in v1.74.0
func (c *Checker) CheckPredefinedRuleExtension( addAnnotationFunc func(bufprotosource.Descriptor, bufprotosource.Location, []bufprotosource.Location, string, ...any), field bufprotosource.Field, ) error
CheckPredefinedRuleExtension checks that a predefined extension is valid, and any CEL expressions compile.