GetEntityByName retrieves an `EntityDefinition` from a `SchemaDefinition` by its name. It returns a pointer to the `EntityDefinition` if it is found in the `SchemaDefinition`. If the `EntityDefinition` is not found, it returns an error with error code `ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND`.
(schema *base.SchemaDefinition, name string)
| 87 | // It returns a pointer to the `EntityDefinition` if it is found in the `SchemaDefinition`. |
| 88 | // If the `EntityDefinition` is not found, it returns an error with error code `ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND`. |
| 89 | func GetEntityByName(schema *base.SchemaDefinition, name string) (entityDefinition *base.EntityDefinition, err error) { |
| 90 | // Look up the entity definition in the schema definition's EntityDefinitions map |
| 91 | if en, ok := schema.GetEntityDefinitions()[name]; ok { |
| 92 | // If the entity definition is found, return it and a nil error |
| 93 | return en, nil |
| 94 | } |
| 95 | // If the entity definition is not found, return a nil entity definition and an error |
| 96 | return nil, errors.New(base.ErrorCode_ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND.String()) |
| 97 | } |
| 98 | |
| 99 | // GetRuleByName retrieves the rule definition from the given schema by its name. |
| 100 | // It takes a pointer to a base.SchemaDefinition and the name of the rule to look for. |
no test coverage detected