@@ -59,22 +59,6 @@ def additionalProperties(validator, aP, instance, schema):
59
59
yield ValidationError (error % _utils .extras_msg (extras ))
60
60
61
61
62
- def items_draft3_draft4 (validator , items , instance , schema ):
63
- if not validator .is_type (instance , "array" ):
64
- return
65
-
66
- if validator .is_type (items , "object" ):
67
- for index , item in enumerate (instance ):
68
- for error in validator .descend (item , items , path = index ):
69
- yield error
70
- else :
71
- for (index , item ), subschema in zip (enumerate (instance ), items ):
72
- for error in validator .descend (
73
- item , subschema , path = index , schema_path = index ,
74
- ):
75
- yield error
76
-
77
-
78
62
def items (validator , items , instance , schema ):
79
63
if not validator .is_type (instance , "array" ):
80
64
return
@@ -132,40 +116,6 @@ def contains(validator, contains, instance, schema):
132
116
)
133
117
134
118
135
- def minimum_draft3_draft4 (validator , minimum , instance , schema ):
136
- if not validator .is_type (instance , "number" ):
137
- return
138
-
139
- if schema .get ("exclusiveMinimum" , False ):
140
- failed = instance <= minimum
141
- cmp = "less than or equal to"
142
- else :
143
- failed = instance < minimum
144
- cmp = "less than"
145
-
146
- if failed :
147
- yield ValidationError (
148
- "%r is %s the minimum of %r" % (instance , cmp , minimum )
149
- )
150
-
151
-
152
- def maximum_draft3_draft4 (validator , maximum , instance , schema ):
153
- if not validator .is_type (instance , "number" ):
154
- return
155
-
156
- if schema .get ("exclusiveMaximum" , False ):
157
- failed = instance >= maximum
158
- cmp = "greater than or equal to"
159
- else :
160
- failed = instance > maximum
161
- cmp = "greater than"
162
-
163
- if failed :
164
- yield ValidationError (
165
- "%r is %s the maximum of %r" % (instance , cmp , maximum )
166
- )
167
-
168
-
169
119
def exclusiveMinimum (validator , minimum , instance , schema ):
170
120
if not validator .is_type (instance , "number" ):
171
121
return
@@ -319,69 +269,6 @@ def ref(validator, ref, instance, schema):
319
269
validator .resolver .pop_scope ()
320
270
321
271
322
- def type_draft3 (validator , types , instance , schema ):
323
- types = _utils .ensure_list (types )
324
-
325
- all_errors = []
326
- for index , type in enumerate (types ):
327
- if validator .is_type (type , "object" ):
328
- errors = list (validator .descend (instance , type , schema_path = index ))
329
- if not errors :
330
- return
331
- all_errors .extend (errors )
332
- else :
333
- if validator .is_type (instance , type ):
334
- return
335
- else :
336
- yield ValidationError (
337
- _utils .types_msg (instance , types ), context = all_errors ,
338
- )
339
-
340
-
341
- def properties_draft3 (validator , properties , instance , schema ):
342
- if not validator .is_type (instance , "object" ):
343
- return
344
-
345
- for property , subschema in iteritems (properties ):
346
- if property in instance :
347
- for error in validator .descend (
348
- instance [property ],
349
- subschema ,
350
- path = property ,
351
- schema_path = property ,
352
- ):
353
- yield error
354
- elif subschema .get ("required" , False ):
355
- error = ValidationError ("%r is a required property" % property )
356
- error ._set (
357
- validator = "required" ,
358
- validator_value = subschema ["required" ],
359
- instance = instance ,
360
- schema = schema ,
361
- )
362
- error .path .appendleft (property )
363
- error .schema_path .extend ([property , "required" ])
364
- yield error
365
-
366
-
367
- def disallow_draft3 (validator , disallow , instance , schema ):
368
- for disallowed in _utils .ensure_list (disallow ):
369
- if validator .is_valid (instance , {"type" : [disallowed ]}):
370
- yield ValidationError (
371
- "%r is disallowed for %r" % (disallowed , instance )
372
- )
373
-
374
-
375
- def extends_draft3 (validator , extends , instance , schema ):
376
- if validator .is_type (extends , "object" ):
377
- for error in validator .descend (instance , extends ):
378
- yield error
379
- return
380
- for index , subschema in enumerate (extends ):
381
- for error in validator .descend (instance , subschema , schema_path = index ):
382
- yield error
383
-
384
-
385
272
def type (validator , types , instance , schema ):
386
273
types = _utils .ensure_list (types )
387
274
@@ -426,56 +313,12 @@ def maxProperties(validator, mP, instance, schema):
426
313
yield ValidationError ("%r has too many properties" % (instance ,))
427
314
428
315
429
- def allOf_draft4 (validator , allOf , instance , schema ):
430
- for index , subschema in enumerate (allOf ):
431
- for error in validator .descend (instance , subschema , schema_path = index ):
432
- yield error
433
-
434
-
435
316
def allOf (validator , allOf , instance , schema ):
436
317
for index , subschema in enumerate (allOf ):
437
318
for error in validator .descend (instance , subschema , schema_path = index ):
438
319
yield error
439
320
440
321
441
- def oneOf_draft4 (validator , oneOf , instance , schema ):
442
- subschemas = enumerate (oneOf )
443
- all_errors = []
444
- for index , subschema in subschemas :
445
- errs = list (validator .descend (instance , subschema , schema_path = index ))
446
- if not errs :
447
- first_valid = subschema
448
- break
449
- all_errors .extend (errs )
450
- else :
451
- yield ValidationError (
452
- "%r is not valid under any of the given schemas" % (instance ,),
453
- context = all_errors ,
454
- )
455
-
456
- more_valid = [s for i , s in subschemas if validator .is_valid (instance , s )]
457
- if more_valid :
458
- more_valid .append (first_valid )
459
- reprs = ", " .join (repr (schema ) for schema in more_valid )
460
- yield ValidationError (
461
- "%r is valid under each of %s" % (instance , reprs )
462
- )
463
-
464
-
465
- def anyOf_draft4 (validator , anyOf , instance , schema ):
466
- all_errors = []
467
- for index , subschema in enumerate (anyOf ):
468
- errs = list (validator .descend (instance , subschema , schema_path = index ))
469
- if not errs :
470
- break
471
- all_errors .extend (errs )
472
- else :
473
- yield ValidationError (
474
- "%r is not valid under any of the given schemas" % (instance ,),
475
- context = all_errors ,
476
- )
477
-
478
-
479
322
def anyOf (validator , anyOf , instance , schema ):
480
323
all_errors = []
481
324
for index , subschema in enumerate (anyOf ):
0 commit comments