forked from miladibra10/vjson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
array_spec.go
23 lines (21 loc) · 880 Bytes
/
array_spec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package vjson
// ArrayFieldSpec is a type used for parsing an ArrayField
type ArrayFieldSpec struct {
Name string `mapstructure:"name"`
Required bool `mapstructure:"required"`
Items map[string]interface{} `mapstructure:"items"`
MinLength int `mapstructure:"min_length"`
MaxLength int `mapstructure:"max_length"`
}
// NewArray receives an ArrayFieldSpec and returns and ArrayField
func NewArray(spec ArrayFieldSpec, itemField Field, minLengthValidation, maxLengthValidation bool) *ArrayField {
return &ArrayField{
name: spec.Name,
required: spec.Required,
items: itemField,
minLength: spec.MinLength,
minLengthValidation: minLengthValidation,
maxLength: spec.MaxLength,
maxLengthValidation: maxLengthValidation,
}
}