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

Function validate

pkg/cmd/validate.go:66–492  ·  view source on GitHub ↗

validate returns a function that validates authorization model with assertions

()

Source from the content-addressed store, hash-verified

64
65// validate returns a function that validates authorization model with assertions
66func validate() func(cmd *cobra.Command, args []string) error {
67 return func(cmd *cobra.Command, args []string) error {
68 // create an empty error list
69 list := &ErrList{
70 Errors: []string{},
71 }
72
73 // create a new context
74 ctx := context.Background()
75
76 // create a new development container
77 dev := development.NewContainer()
78
79 // parse the url from the first argument
80 u, err := url.Parse(args[0])
81 if err != nil {
82 return err
83 }
84
85 // create a new decoder from the url
86 decoder, err := file.NewDecoderFromURL(u)
87 if err != nil {
88 return err
89 }
90
91 // create a new shape
92 s := &file.Shape{}
93
94 // decode the schema from the decoder
95 err = decoder.Decode(s)
96 if err != nil {
97 return err
98 }
99
100 // if debug is true, print schema is creating with color blue
101 color.Notice.Println("schema is creating... 🚀")
102 // Load and parse schema
103 loader := schema.NewSchemaLoader() // Create schema loader
104 loaded, err := loader.LoadSchema(s.Schema) // Load schema content
105 if err != nil { // Check for loading errors
106 return err // Return error if loading fails
107 } // Schema loaded successfully
108 // Parse loaded schema
109 sch, err := parser.NewParser(loaded).Parse()
110 if err != nil {
111 return err
112 }
113
114 _, _, err = compiler.NewCompiler(true, sch).Compile()
115 if err != nil {
116 return err
117 }
118
119 version := xid.New().String()
120
121 cnf := make([]storage.SchemaDefinition, 0, len(sch.Statements))
122 for _, st := range sch.Statements {
123 cnf = append(cnf, storage.SchemaDefinition{

Callers 2

coverageFunction · 0.85
NewValidateCommandFunction · 0.85

Calls 15

AddMethod · 0.95
PrintMethod · 0.95
GetEntityMethod · 0.95
GetEntityMethod · 0.95
NewContainerFunction · 0.92
NewDecoderFromURLFunction · 0.92
NewSchemaLoaderFunction · 0.92
NewParserFunction · 0.92
NewCompilerFunction · 0.92
TupleFunction · 0.92
NewTupleCollectionFunction · 0.92
NewAttributeCollectionFunction · 0.92

Tested by

no test coverage detected