forked from tidepool-org/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bool.go
50 lines (43 loc) · 840 Bytes
/
bool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package validator
import (
"github.com/tidepool-org/platform/structure"
structureBase "github.com/tidepool-org/platform/structure/base"
)
type Bool struct {
base *structureBase.Base
value *bool
}
func NewBool(base *structureBase.Base, value *bool) *Bool {
return &Bool{
base: base,
value: value,
}
}
func (b *Bool) Exists() structure.Bool {
if b.value == nil {
b.base.ReportError(ErrorValueNotExists())
}
return b
}
func (b *Bool) NotExists() structure.Bool {
if b.value != nil {
b.base.ReportError(ErrorValueExists())
}
return b
}
func (b *Bool) True() structure.Bool {
if b.value != nil {
if !*b.value {
b.base.ReportError(ErrorValueNotTrue())
}
}
return b
}
func (b *Bool) False() structure.Bool {
if b.value != nil {
if *b.value {
b.base.ReportError(ErrorValueNotFalse())
}
}
return b
}