MCPcopy Index your code
hub / github.com/git-bug/git-bug / Validate

Method Validate

entities/bug/bug.go:87–109  ·  view source on GitHub ↗

Validate check if the Bug data is valid

()

Source from the content-addressed store, hash-verified

85
86// Validate check if the Bug data is valid
87func (bug *Bug) Validate() error {
88 if err := bug.Entity.Validate(); err != nil {
89 return err
90 }
91
92 // The very first Op should be a CreateOp
93 firstOp := bug.FirstOp()
94 if firstOp == nil || firstOp.Type() != CreateOp {
95 return fmt.Errorf("first operation should be a Create op")
96 }
97
98 // Check that there is no more CreateOp op
99 for i, op := range bug.Entity.Operations() {
100 if i == 0 {
101 continue
102 }
103 if op.Type() == CreateOp {
104 return fmt.Errorf("only one Create op allowed")
105 }
106 }
107
108 return nil
109}
110
111// Append add a new Operation to the Bug
112func (bug *Bug) Append(op Operation) {

Callers

nothing calls this directly

Calls 5

FirstOpMethod · 0.95
ErrorfMethod · 0.80
ValidateMethod · 0.65
TypeMethod · 0.65
OperationsMethod · 0.65

Tested by

no test coverage detected