MCPcopy Create free account
hub / github.com/Permify/permify / IsAttributeFilterEmpty

Function IsAttributeFilterEmpty

internal/validation/validation.go:149–167  ·  view source on GitHub ↗

IsAttributeFilterEmpty checks if the provided AttributeFilter object is empty. An AttributeFilter is considered empty if none of its fields have been set.

(filter *base.AttributeFilter)

Source from the content-addressed store, hash-verified

147// IsAttributeFilterEmpty checks if the provided AttributeFilter object is empty.
148// An AttributeFilter is considered empty if none of its fields have been set.
149func IsAttributeFilterEmpty(filter *base.AttributeFilter) bool {
150 // Check if the Entity type field of the filter is set. If it is, the filter is not empty.
151 if filter.GetEntity().GetType() != "" {
152 return false // Entity type is specified, hence the filter is not empty.
153 }
154
155 // Check if the Entity IDs field of the filter has any IDs. If it does, the filter is not empty.
156 if len(filter.GetEntity().GetIds()) > 0 {
157 return false // Entity IDs are specified, hence the filter is not empty.
158 }
159
160 // Check if the Attributes field of the filter has any attributes set. If it does, the filter is not empty.
161 if len(filter.GetAttributes()) > 0 {
162 return false // Attributes are specified, hence the filter is not empty.
163 }
164
165 // If none of the above fields are set, then the filter is considered empty.
166 return true
167}
168
169// ValidateBundleOperation checks for duplicate keys in various operations of a bundle.
170func ValidateBundleOperation(op *base.Operation) error {

Callers 4

deleteMethod · 0.92
DeleteMethod · 0.92
validation_test.goFile · 0.85
ValidateFiltersFunction · 0.85

Calls 4

GetTypeMethod · 0.65
GetEntityMethod · 0.45
GetIdsMethod · 0.45
GetAttributesMethod · 0.45

Tested by

no test coverage detected