fieldbehavior

package
v0.67.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 5 Imported by: 6

Documentation

Overview

Package fieldbehavior provides primitives for implementing AIP fieldbehavior annotations.

See: https://google.aip.dev/203 (Field behavior documentation)

Index

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.

See: https://google.aip.dev/161#output-only-fields

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

Get returns the field behavior of the provided field descriptor.

func Has

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

func ValidateRequiredFields(m proto.Message) error

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.

Jump to

Keyboard shortcuts

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