@@ -64,21 +64,27 @@ def _is_re_match(value):
64
64
return _all (_hasattr (value , a ) for a in _re_match_attr )
65
65
66
66
67
- class any (tuple ):
68
- """At least one of the schemas must be valid."""
69
- def __new__ (cls , * args ):
70
- return super (any , cls ).__new__ (cls , args )
67
+ class SchemaContainer (object ):
68
+ def __init__ (self , schema ):
69
+ self .schema = schema
71
70
72
71
73
- class all ( tuple ):
74
- """All schemas must be valid."""
75
- def __new__ ( cls , * args ):
76
- return super ( all , cls ). __new__ ( cls , args )
72
+ class any ( SchemaContainer ):
73
+ """
74
+ Collection of schemas where at least one schema must be valid.
75
+ """
77
76
77
+ def __init__ (self , * schemas ):
78
+ super (any , self ).__init__ (schemas )
78
79
79
- class SchemaContainer (object ):
80
- def __init__ (self , schema ):
81
- self .schema = schema
80
+
81
+ class all (SchemaContainer ):
82
+ """
83
+ Collection of schemas where every schema must be valid.
84
+ """
85
+
86
+ def __init__ (self , * schemas ):
87
+ super (all , self ).__init__ (schemas )
82
88
83
89
84
90
class transform (object ):
@@ -390,7 +396,7 @@ def validate(schema, value):
390
396
@validate .register (any )
391
397
def validate_any (schema , value ):
392
398
errors = []
393
- for subschema in schema :
399
+ for subschema in schema . schema :
394
400
try :
395
401
return validate (subschema , value )
396
402
except ValueError as err :
@@ -401,8 +407,8 @@ def validate_any(schema, value):
401
407
402
408
403
409
@validate .register (all )
404
- def validate_all (schemas , value ):
405
- for schema in schemas :
410
+ def validate_all (schema , value ):
411
+ for schema in schema . schema :
406
412
value = validate (schema , value )
407
413
408
414
return value
0 commit comments