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

Function GetAttributeByNameInEntityDefinition

internal/schema/schema.go:156–164  ·  view source on GitHub ↗

GetAttributeByNameInEntityDefinition retrieves an `AttributeDefinition` from an `EntityDefinition` by its name. It returns a pointer to the `AttributeDefinition` if it is found in the `EntityDefinition`. If the `AttributeDefinition` is not found, it returns an error with error code `ERROR_CODE_ATTRI

(entityDefinition *base.EntityDefinition, name string)

Source from the content-addressed store, hash-verified

154// It returns a pointer to the `AttributeDefinition` if it is found in the `EntityDefinition`.
155// If the `AttributeDefinition` is not found, it returns an error with error code `ERROR_CODE_ATTRIBUTE_DEFINITION_NOT_FOUND`.
156func GetAttributeByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (attributeDefinition *base.AttributeDefinition, err error) {
157 // Look up the attribute definition in the entity definition's Attributes map
158 if ad, ok := entityDefinition.GetAttributes()[name]; ok {
159 // If the attribute definition is found, return it and a nil error
160 return ad, nil
161 }
162 // If the attribute definition is not found, return a nil attribute definition and an error
163 return nil, errors.New(base.ErrorCode_ERROR_CODE_ATTRIBUTE_DEFINITION_NOT_FOUND.String())
164}
165
166// IsDirectlyRelated checks if a source `RelationReference` is directly related to a target `RelationDefinition`.
167// It returns true if the source and target have the same type and relation, false otherwise.

Callers 2

ValidateAttributeFunction · 0.92
schema_test.goFile · 0.85

Calls 2

StringMethod · 0.65
GetAttributesMethod · 0.45

Tested by

no test coverage detected