Add jsonschema Validate

This commit is contained in:
George Suntres
2026-03-29 12:01:48 -04:00
parent ebdf370c23
commit 434ecef67a
6 changed files with 164 additions and 3 deletions

View File

@@ -4,6 +4,42 @@ import (
"testing"
)
func TestStructToMapRecursive(t *testing.T) {
type O struct {
Name string
Age int
Active bool
}
o := &O{
Name: "Nick",
Age: 15,
Active: true,
}
mAny := StructToMapRecursive(o)
switch mAny.(type) {
case map[string]any:
m := mAny.(map[string]any)
if v, ok := m["Name"]; !ok || v != "Nick" {
t.Fatalf("Unexpected map %v", v)
}
if v, ok := m["Age"]; !ok || v != 15 {
t.Fatalf("Unexpected map %v", v)
}
if v, ok := m["Active"]; !ok || v != true {
t.Fatalf("Unexpected map %v", v)
}
default:
t.Fatal("is not map")
}
}
func TestMapToStruct(t *testing.T) {
o := map[string]any {
"name": "name1",