@@ -35,7 +35,7 @@ type SchemaValidator struct {
35
35
Path string
36
36
in string
37
37
Schema * spec.Schema
38
- validators []valueValidator
38
+ validators []ValueValidator
39
39
Root interface {}
40
40
KnownFormats strfmt.Registry
41
41
Options SchemaValidatorOptions
@@ -79,12 +79,12 @@ func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string
79
79
o (& s .Options )
80
80
}
81
81
82
- if s .Options .subIndexValidator == nil {
83
- s .Options .subPropertyValidator = s .SubPropertyValidator
84
- s .Options .subIndexValidator = s .SubIndexValidator
82
+ if s .Options .NewValidatorForIndex == nil {
83
+ s .Options .NewValidatorForField = s .NewValidatorForField
84
+ s .Options .NewValidatorForIndex = s .NewValidatorForIndex
85
85
}
86
86
87
- s .validators = []valueValidator {
87
+ s .validators = []ValueValidator {
88
88
s .typeValidator (),
89
89
s .schemaPropsValidator (),
90
90
s .stringValidator (),
@@ -97,12 +97,12 @@ func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string
97
97
return & s
98
98
}
99
99
100
- func (s * SchemaValidator ) SubPropertyValidator (field string , sch * spec.Schema ) valueValidator {
101
- return NewSchemaValidator (sch , s . Root , s . Path + "." + field , s . KnownFormats , s . Options . Options () ... )
100
+ func (s * SchemaValidator ) NewValidatorForField (field string , schema * spec.Schema , rootSchema interface {}, root string , formats strfmt. Registry , opts ... Option ) ValueValidator {
101
+ return NewSchemaValidator (schema , rootSchema , root , formats , opts ... )
102
102
}
103
103
104
- func (s * SchemaValidator ) SubIndexValidator (index int , sch * spec.Schema ) valueValidator {
105
- return NewSchemaValidator (sch , s . Root , fmt . Sprintf ( "%s[%d]" , s . Path , index ), s . KnownFormats , s . Options . Options () ... )
104
+ func (s * SchemaValidator ) NewValidatorForIndex (index int , schema * spec.Schema , rootSchema interface {}, root string , formats strfmt. Registry , opts ... Option ) ValueValidator {
105
+ return NewSchemaValidator (schema , rootSchema , root , formats , opts ... )
106
106
}
107
107
108
108
// SetPath sets the path for this schema validator
@@ -188,19 +188,19 @@ func (s *SchemaValidator) Validate(data interface{}) *Result {
188
188
return result
189
189
}
190
190
191
- func (s * SchemaValidator ) typeValidator () valueValidator {
191
+ func (s * SchemaValidator ) typeValidator () ValueValidator {
192
192
return & typeValidator {Type : s .Schema .Type , Nullable : s .Schema .Nullable , Format : s .Schema .Format , In : s .in , Path : s .Path }
193
193
}
194
194
195
- func (s * SchemaValidator ) commonValidator () valueValidator {
195
+ func (s * SchemaValidator ) commonValidator () ValueValidator {
196
196
return & basicCommonValidator {
197
197
Path : s .Path ,
198
198
In : s .in ,
199
199
Enum : s .Schema .Enum ,
200
200
}
201
201
}
202
202
203
- func (s * SchemaValidator ) sliceValidator () valueValidator {
203
+ func (s * SchemaValidator ) sliceValidator () ValueValidator {
204
204
return & schemaSliceValidator {
205
205
Path : s .Path ,
206
206
In : s .in ,
@@ -215,7 +215,7 @@ func (s *SchemaValidator) sliceValidator() valueValidator {
215
215
}
216
216
}
217
217
218
- func (s * SchemaValidator ) numberValidator () valueValidator {
218
+ func (s * SchemaValidator ) numberValidator () ValueValidator {
219
219
return & numberValidator {
220
220
Path : s .Path ,
221
221
In : s .in ,
@@ -228,7 +228,7 @@ func (s *SchemaValidator) numberValidator() valueValidator {
228
228
}
229
229
}
230
230
231
- func (s * SchemaValidator ) stringValidator () valueValidator {
231
+ func (s * SchemaValidator ) stringValidator () ValueValidator {
232
232
return & stringValidator {
233
233
Path : s .Path ,
234
234
In : s .in ,
@@ -238,7 +238,7 @@ func (s *SchemaValidator) stringValidator() valueValidator {
238
238
}
239
239
}
240
240
241
- func (s * SchemaValidator ) formatValidator () valueValidator {
241
+ func (s * SchemaValidator ) formatValidator () ValueValidator {
242
242
return & formatValidator {
243
243
Path : s .Path ,
244
244
In : s .in ,
@@ -247,12 +247,12 @@ func (s *SchemaValidator) formatValidator() valueValidator {
247
247
}
248
248
}
249
249
250
- func (s * SchemaValidator ) schemaPropsValidator () valueValidator {
250
+ func (s * SchemaValidator ) schemaPropsValidator () ValueValidator {
251
251
sch := s .Schema
252
252
return newSchemaPropsValidator (s .Path , s .in , sch .AllOf , sch .OneOf , sch .AnyOf , sch .Not , sch .Dependencies , s .Root , s .KnownFormats , s .Options .Options ()... )
253
253
}
254
254
255
- func (s * SchemaValidator ) objectValidator () valueValidator {
255
+ func (s * SchemaValidator ) objectValidator () ValueValidator {
256
256
return & objectValidator {
257
257
Path : s .Path ,
258
258
In : s .in ,
0 commit comments