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

rom8726 / floxy / 18850030231

27 Oct 2025 05:23PM UTC coverage: 37.585% (-0.1%) from 37.733%
18850030231

push

github

rom8726
Validate Engine Plugin implemented.

0 of 27 new or added lines in 1 file covered. (0.0%)

2590 of 6891 relevant lines covered (37.59%)

31.89 hits per line

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

0.0
/plugins/engine/validate/plugin.go
1
package validate
2

3
import (
4
        "context"
5
        "encoding/json"
6
        "fmt"
7
        "sync"
8

9
        "github.com/rom8726/floxy"
10
)
11

12
var _ floxy.Plugin = (*ValidationPlugin)(nil)
13

14
type ValidationRule func(data json.RawMessage) error
15

16
type ValidationPlugin struct {
17
        floxy.BasePlugin
18

19
        rules map[string][]ValidationRule
20
        mu    sync.RWMutex
21
}
22

NEW
23
func New() *ValidationPlugin {
×
NEW
24
        return &ValidationPlugin{
×
NEW
25
                BasePlugin: floxy.NewBasePlugin("validation", floxy.PriorityHigh),
×
NEW
26
                rules:      make(map[string][]ValidationRule),
×
NEW
27
        }
×
NEW
28
}
×
29

NEW
30
func (p *ValidationPlugin) AddRule(stepName string, rule ValidationRule) {
×
NEW
31
        p.mu.Lock()
×
NEW
32
        defer p.mu.Unlock()
×
NEW
33

×
NEW
34
        if _, exists := p.rules[stepName]; !exists {
×
NEW
35
                p.rules[stepName] = make([]ValidationRule, 0)
×
NEW
36
        }
×
37

NEW
38
        p.rules[stepName] = append(p.rules[stepName], rule)
×
39
}
40

41
func (p *ValidationPlugin) OnStepStart(
42
        _ context.Context,
43
        _ *floxy.WorkflowInstance,
44
        step *floxy.WorkflowStep,
NEW
45
) error {
×
NEW
46
        p.mu.RLock()
×
NEW
47
        rules, exists := p.rules[step.StepName]
×
NEW
48
        p.mu.RUnlock()
×
NEW
49

×
NEW
50
        if !exists {
×
NEW
51
                return nil
×
NEW
52
        }
×
53

NEW
54
        for i, rule := range rules {
×
NEW
55
                if err := rule(step.Input); err != nil {
×
NEW
56
                        return fmt.Errorf("validation rule %d failed for step %q: %w", i, step.StepName, err)
×
NEW
57
                }
×
58
        }
59

NEW
60
        return nil
×
61
}
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