MCPcopy Create free account
hub / github.com/RussellLuo/validating / makeSchema1_Map

Function makeSchema1_Map

example_nested_struct_map_test.go:34–48  ·  view source on GitHub ↗

The equivalent implementation using Map. nolint:golint,unused

(p *Person1)

Source from the content-addressed store, hash-verified

32//
33//nolint:golint,unused
34func makeSchema1_Map(p *Person1) v.Schema {
35 return v.Schema{
36 v.F("name", p.Name): v.LenString(1, 5),
37 v.F("age", p.Age): v.Nonzero[int](),
38 v.F("family", p.Family): v.Map(func(m map[string]*Member) map[string]v.Validator {
39 schemas := make(map[string]v.Validator)
40 for relation, member := range m {
41 schemas[relation] = v.Schema{
42 v.F("name", member.Name): v.LenString(10, 15).Msg("is too long"),
43 }
44 }
45 return schemas
46 }),
47 }
48}
49
50func Example_nestedStructMap() {
51 p1 := Person1{}

Callers

nothing calls this directly

Calls 2

MapMethod · 0.80
MsgMethod · 0.80

Tested by

no test coverage detected