-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParserStatus.go
43 lines (39 loc) · 880 Bytes
/
ParserStatus.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
package cff
import (
"errors"
"gopkg.in/yaml.v3"
)
//MarshalYAML serialises the STATUS to YAML and validates the data
func (t STATUS) MarshalYAML() (interface{}, error) {
if !STATUSExists(string(t)) {
return nil, errors.New("invalid Status: " + string(t))
}
return string(t), nil
}
//UnmarshalYAML checks if the data is a valid STATUS
func (t *STATUS) UnmarshalYAML(v *yaml.Node) error {
if !STATUSExists(v.Value) {
return errors.New("STATUS does not exist")
}
*t = STATUS(v.Value)
return nil
}
//STATUSExists checks if a STATUS exists
func STATUSExists(status string) bool {
switch STATUS(status) {
case STATUS_abstract:
return true
case STATUS_advanceOnline:
return true
case STATUS_inPreparation:
return true
case STATUS_inPress:
return true
case STATUS_preprint:
return true
case STATUS_submitted:
return true
default:
return false
}
}