Documentation ¶
Overview ¶
Package fieldbehavior provides primitives for implementing AIP fieldbehavior annotations.
See: https://google.aip.dev/203 (Field behavior documentation)
Index ¶
- func ClearFields(message proto.Message, behaviorsToClear ...annotations.FieldBehavior)
- func CopyFields(dst, src proto.Message, behaviorsToCopy ...annotations.FieldBehavior)
- func Get(field protoreflect.FieldDescriptor) []annotations.FieldBehavior
- func Has(field protoreflect.FieldDescriptor, want annotations.FieldBehavior) bool
- func ValidateImmutableFieldsWithMask(m proto.Message, mask *fieldmaskpb.FieldMask) error
- func ValidateRequiredFields(m proto.Message) error
- func ValidateRequiredFieldsWithMask(m proto.Message, mask *fieldmaskpb.FieldMask) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearFields ¶
func ClearFields(message proto.Message, behaviorsToClear ...annotations.FieldBehavior)
ClearFields clears all fields annotated with any of the provided behaviors. This can be used to ignore fields provided as input that have field_behavior's such as OUTPUT_ONLY and IMMUTABLE.
func CopyFields ¶
func CopyFields(dst, src proto.Message, behaviorsToCopy ...annotations.FieldBehavior)
CopyFields copies all fields annotated with any of the provided behaviors from src to dst.
func Get ¶
func Get(field protoreflect.FieldDescriptor) []annotations.FieldBehavior
Get returns the field behavior of the provided field descriptor.
func Has ¶
func Has(field protoreflect.FieldDescriptor, want annotations.FieldBehavior) bool
Has returns true if the provided field descriptor has the wanted field behavior.
func ValidateImmutableFieldsWithMask ¶ added in v0.59.0
func ValidateImmutableFieldsWithMask(m proto.Message, mask *fieldmaskpb.FieldMask) error
ValidateImmutableFieldsWithMask returns a validation error if the message or field mask contains a field that is immutable and a change to an immutable field is requested. This can be used when validating update requests and want to return INVALID_ARGUMENT to the user. If you want to ignore immutable fields rather than error then use ClearFields().
See: https://aip.dev/203
func ValidateRequiredFields ¶
ValidateRequiredFields returns a validation error if any field annotated as required does not have a value. See: https://aip.dev/203
func ValidateRequiredFieldsWithMask ¶
func ValidateRequiredFieldsWithMask(m proto.Message, mask *fieldmaskpb.FieldMask) error
Types ¶
This section is empty.