-
Notifications
You must be signed in to change notification settings - Fork 18
/
default.go
45 lines (38 loc) · 1.09 KB
/
default.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
package parseable
import (
"github.com/cirruslabs/cirrus-cli/pkg/parser/nameable"
"github.com/lestrrat-go/jsschema"
)
type DefaultParser struct {
fields []Field
collectibleFields []CollectibleField
collectible bool
}
func (parser *DefaultParser) OptionalField(name nameable.Nameable, schema *schema.Schema, onFound nodeFunc) {
parser.fields = append(parser.fields, Field{
name: name,
onFound: onFound,
schema: schema,
})
}
func (parser *DefaultParser) RequiredField(nameable nameable.Nameable, schema *schema.Schema, onFound nodeFunc) {
parser.fields = append(parser.fields, Field{
name: nameable,
required: true,
onFound: onFound,
schema: schema,
})
}
func (parser *DefaultParser) CollectibleField(name string, schema *schema.Schema, onFound nodeFunc) {
parser.collectibleFields = append(parser.collectibleFields, CollectibleField{
Name: name,
onFound: onFound,
Schema: schema,
})
}
func (parser *DefaultParser) Collectible() bool {
return parser.collectible
}
func (parser *DefaultParser) SetCollectible(value bool) {
parser.collectible = value
}