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

Function ValidateFilters

internal/validation/validation.go:60–70  ·  view source on GitHub ↗

ValidateFilters checks if both provided filters, tupleFilter and attributeFilter, are empty. It returns an error if both filters are empty, as at least one filter should contain criteria for the operation to be valid.

(tupleFilter *base.TupleFilter, attributeFilter *base.AttributeFilter)

Source from the content-addressed store, hash-verified

58// ValidateFilters checks if both provided filters, tupleFilter and attributeFilter, are empty.
59// It returns an error if both filters are empty, as at least one filter should contain criteria for the operation to be valid.
60func ValidateFilters(tupleFilter *base.TupleFilter, attributeFilter *base.AttributeFilter) (err error) {
61 // Check if both tupleFilter and attributeFilter are empty using the respective functions.
62 // If both are empty, then there is nothing to validate, and an error is returned.
63 if IsTupleFilterEmpty(tupleFilter) && IsAttributeFilterEmpty(attributeFilter) {
64 // The error returned indicates a validation error due to both filters being empty.
65 return errors.New(base.ErrorCode_ERROR_CODE_VALIDATION.String())
66 }
67
68 // If at least one of the filters is not empty, then the validation is successful, and no error is returned.
69 return nil
70}
71
72// ValidateAttribute checks whether a given attribute request (reqAttribute) aligns with
73// the attribute definition in a given entity definition. It verifies if the attribute exists

Callers 2

DeleteMethod · 0.92
validation_test.goFile · 0.85

Calls 3

IsTupleFilterEmptyFunction · 0.85
IsAttributeFilterEmptyFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected