initial dump

This commit is contained in:
Ricardo (XenGi) Band 2022-11-08 16:44:59 +01:00
commit b7eed22fa4
No known key found for this signature in database
6 changed files with 214 additions and 0 deletions

33
main.go Normal file
View file

@ -0,0 +1,33 @@
package main
import (
"fmt"
"github.com/xeipuuv/gojsonschema"
"os"
"path/filepath"
)
func main() {
ex, err := os.Executable()
if err != nil {
panic(err)
}
exPath := filepath.Dir(ex)
schemaLoader := gojsonschema.NewReferenceLoader(fmt.Sprintf("file://%s/schema.json", exPath))
documentLoader := gojsonschema.NewReferenceLoader(fmt.Sprintf("file://%s/vars.json", exPath))
result, err := gojsonschema.Validate(schemaLoader, documentLoader)
if err != nil {
panic(err.Error())
}
if result.Valid() {
fmt.Println("The document is valid")
} else {
fmt.Println("The document is not valid. see errors:")
for _, desc := range result.Errors() {
fmt.Println("-", desc)
}
}
}