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

Method Validate

pkg/dsl/ast/validation.go:13–32  ·  view source on GitHub ↗

Validate - validates the schema to ensure that it meets certain requirements.

()

Source from the content-addressed store, hash-verified

11
12// Validate - validates the schema to ensure that it meets certain requirements.
13func (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.
35func (sch *Schema) validateRelationTypeStatement(ref RelationTypeStatement) error {

Callers 15

CompileMethod · 0.45
WatchMethod · 0.45
WriteMethod · 0.45
ReadMethod · 0.45
DeleteMethod · 0.45
ReadRelationshipsMethod · 0.45
ReadAttributesMethod · 0.45
WriteMethod · 0.45
WriteRelationshipsMethod · 0.45
DeleteMethod · 0.45
DeleteRelationshipsMethod · 0.45
RunBundleMethod · 0.45

Calls 4

GetReferencesMethod · 0.95
validationErrorFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected