validateRelationTypeStatement - validates a single relation type statement to ensure that it meets certain requirements.
(ref RelationTypeStatement)
| 33 | |
| 34 | // validateRelationTypeStatement - validates a single relation type statement to ensure that it meets certain requirements. |
| 35 | func (sch *Schema) validateRelationTypeStatement(ref RelationTypeStatement) error { |
| 36 | // Check that the entity reference in the relation type statement is valid. |
| 37 | if !sch.GetReferences().IsEntityReferenceExist(ref.Type.Literal) { |
| 38 | return validationError(ref.Type.PositionInfo, base.ErrorCode_ERROR_CODE_RELATION_REFERENCE_NOT_FOUND_IN_ENTITY_REFERENCES.String()) |
| 39 | } |
| 40 | // If the relation type statement does not have a direct entity reference, check that the relation reference is valid. |
| 41 | if !IsDirectEntityReference(ref) { |
| 42 | if !sch.GetReferences().IsRelationReferenceExist(ref.Type.Literal + "#" + ref.Relation.Literal) { |
| 43 | return validationError(ref.Type.PositionInfo, base.ErrorCode_ERROR_CODE_RELATION_REFERENCE_NOT_FOUND_IN_ENTITY_REFERENCES.String()) |
| 44 | } |
| 45 | } |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | // validationError - returns a formatted error message. |
| 50 | func validationError(info token.PositionInfo, message string) error { |
no test coverage detected