...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package validate
16
17
18 type SchemaValidatorOptions struct {
19 EnableObjectArrayTypeCheck bool
20 EnableArrayMustHaveItemsCheck bool
21 recycleValidators bool
22 recycleResult bool
23 skipSchemataResult bool
24 }
25
26
27 type Option func(*SchemaValidatorOptions)
28
29
30 func EnableObjectArrayTypeCheck(enable bool) Option {
31 return func(svo *SchemaValidatorOptions) {
32 svo.EnableObjectArrayTypeCheck = enable
33 }
34 }
35
36
37 func EnableArrayMustHaveItemsCheck(enable bool) Option {
38 return func(svo *SchemaValidatorOptions) {
39 svo.EnableArrayMustHaveItemsCheck = enable
40 }
41 }
42
43
44 func SwaggerSchema(enable bool) Option {
45 return func(svo *SchemaValidatorOptions) {
46 svo.EnableObjectArrayTypeCheck = enable
47 svo.EnableArrayMustHaveItemsCheck = enable
48 }
49 }
50
51
52
53
54
55 func WithRecycleValidators(enable bool) Option {
56 return func(svo *SchemaValidatorOptions) {
57 svo.recycleValidators = enable
58 }
59 }
60
61 func withRecycleResults(enable bool) Option {
62 return func(svo *SchemaValidatorOptions) {
63 svo.recycleResult = enable
64 }
65 }
66
67
68 func WithSkipSchemataResult(enable bool) Option {
69 return func(svo *SchemaValidatorOptions) {
70 svo.skipSchemataResult = enable
71 }
72 }
73
74
75 func (svo SchemaValidatorOptions) Options() []Option {
76 return []Option{
77 EnableObjectArrayTypeCheck(svo.EnableObjectArrayTypeCheck),
78 EnableArrayMustHaveItemsCheck(svo.EnableArrayMustHaveItemsCheck),
79 WithRecycleValidators(svo.recycleValidators),
80 withRecycleResults(svo.recycleResult),
81 WithSkipSchemataResult(svo.skipSchemataResult),
82 }
83 }
84
View as plain text