NewSchemaFromStringDefinitions creates a new `SchemaDefinition` from a list of string definitions. The `validation` argument determines whether to validate the input definitions before creating the schema. If the validation is successful, it returns a pointer to the newly created `SchemaDefinition`.
(validation bool, definitions ...string)
| 14 | // If the validation is successful, it returns a pointer to the newly created `SchemaDefinition`. |
| 15 | // If there's an error during validation or creating the schema, it returns an error. |
| 16 | func NewSchemaFromStringDefinitions(validation bool, definitions ...string) (*base.SchemaDefinition, error) { |
| 17 | // Create entity definitions from the input string definitions |
| 18 | en, ru, err := NewEntityAndRuleDefinitionsFromStringDefinitions(validation, definitions...) |
| 19 | if err != nil { |
| 20 | // If there's an error, return the error |
| 21 | return nil, err |
| 22 | } |
| 23 | // Create a schema from the entity definitions |
| 24 | return NewSchemaFromEntityAndRuleDefinitions(en, ru), nil |
| 25 | } |
| 26 | |
| 27 | // NewSchemaFromEntityAndRuleDefinitions creates a new base.SchemaDefinition from entity and rule definitions. |
| 28 | // It takes two slices of pointers to base.EntityDefinition and base.RuleDefinition, representing the entities and rules to include in the schema. |
no test coverage detected