• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Oudwins / zog / 25961110978

16 May 2026 11:46AM UTC coverage: 78.597% (-0.3%) from 78.85%
25961110978

push

github

web-flow
refactor: zss validation and typing refactor (#223)

* refactor: change zss structure

* feat: update schema definition

* feat: recursive serialization

* chore

* wp

* feat: regex for versions

* wp

* wp

* chore

* chore

* fix: review

* chore

23 of 74 new or added lines in 7 files covered. (31.08%)

1 existing line in 1 file now uncovered.

2890 of 3677 relevant lines covered (78.6%)

70.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.21
/recursive.go
1
package zog
2

3
import (
4
        "sync"
5

6
        p "github.com/Oudwins/zog/pkgs/internals"
7
        zss "github.com/Oudwins/zog/pkgs/zss/core"
8
        "github.com/Oudwins/zog/zconst"
9
)
10

11
type lazySchema struct {
12
        innerSchema ZogSchema
13
        fn          func() ZogSchema
14
        once        sync.Once
15
}
16

17
var _ ZogSchema = &lazySchema{}
18

19
func (l *lazySchema) get() ZogSchema {
114✔
20
        l.once.Do(func() {
136✔
21
                l.innerSchema = l.fn()
22✔
22
        })
22✔
23
        return l.innerSchema
114✔
24
}
25

26
func (l *lazySchema) process(ctx *p.SchemaCtx) {
49✔
27
        l.get().process(ctx)
49✔
28
}
49✔
29
func (l *lazySchema) validate(ctx *p.SchemaCtx) {
6✔
30
        l.get().validate(ctx)
6✔
31
}
6✔
32
func (l *lazySchema) getType() zconst.ZogType  { return l.get().getType() }
59✔
33
func (l *lazySchema) setCoercer(c CoercerFunc) { l.get().setCoercer(c) }
×
NEW
34
func (l *lazySchema) toZSS(ctx *ZSSSerializeCtx) *zss.ZSSSchema {
×
NEW
35
        return ctx.refFor(l.get().(ZSSSerializable))
×
NEW
36
}
×
37

38
func lazy(fn func() ZogSchema) *lazySchema {
24✔
39
        return &lazySchema{fn: fn}
24✔
40
}
24✔
41

42
type RecursiveSchemaUpdater[T ZogSchema] func(self T) T
43
type RecursiveSchema[T ZogSchema] func(updaters ...RecursiveSchemaUpdater[T]) ZogSchema
44
type RecursiveSchemaBuilder[T ZogSchema] func(self RecursiveSchema[T]) T
45

46
// Experimental API.
47
// Do not use unless you know what you are doing.
48
func EXPERIMENTAL_RECURSIVE[T ZogSchema](build RecursiveSchemaBuilder[T]) T {
23✔
49
        var self T
23✔
50
        var lazyBuilder RecursiveSchema[T] = func(updaters ...RecursiveSchemaUpdater[T]) ZogSchema {
47✔
51
                return lazy(func() ZogSchema {
46✔
52
                        if len(updaters) > 0 {
25✔
53
                                return updaters[0](self)
3✔
54
                        }
3✔
55
                        return self
19✔
56
                })
57
        }
58
        self = build(lazyBuilder)
23✔
59
        return self
23✔
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc