Validate - validates the schema to ensure that it meets certain requirements.
()
| 11 | |
| 12 | // Validate - validates the schema to ensure that it meets certain requirements. |
| 13 | func (sch *Schema) Validate() error { |
| 14 | if len(sch.GetReferences().entityReferences) == 0 { |
| 15 | return validationError(token.PositionInfo{ |
| 16 | LinePosition: 1, |
| 17 | ColumnPosition: 1, |
| 18 | }, base.ErrorCode_ERROR_CODE_NO_ENTITY_REFERENCES_FOUND_IN_SCHEMA.String()) |
| 19 | } |
| 20 | |
| 21 | // Loop through all relation references in the schema. |
| 22 | for _, st := range sch.GetReferences().relationReferences { |
| 23 | // Loop through all relation type statements in the relation reference. |
| 24 | for _, s := range st { |
| 25 | // Check that the relation type statement is valid. |
| 26 | if sch.validateRelationTypeStatement(s) != nil { |
| 27 | return validationError(s.Type.PositionInfo, base.ErrorCode_ERROR_CODE_RELATION_REFERENCE_NOT_FOUND_IN_ENTITY_REFERENCES.String()) |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | return nil |
| 32 | } |
| 33 | |
| 34 | // validateRelationTypeStatement - validates a single relation type statement to ensure that it meets certain requirements. |
| 35 | func (sch *Schema) validateRelationTypeStatement(ref RelationTypeStatement) error { |
no test coverage detected