initial dump
This commit is contained in:
parent
c4b782cd33
commit
b7eed22fa4
6 changed files with 214 additions and 0 deletions
33
main.go
Normal file
33
main.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue