@@ -77,7 +77,7 @@ def __init__(self, *schemas):
77
77
super (all , self ).__init__ (schemas )
78
78
79
79
80
- class get :
80
+ class get ( object ) :
81
81
"""
82
82
Get item from input.
83
83
@@ -128,7 +128,7 @@ def __init__(self, *keys, **kw):
128
128
self .seq = kw .get ("seq" , tuple )
129
129
130
130
131
- class xml_element :
131
+ class xml_element ( object ) :
132
132
"""
133
133
Validate an XML element.
134
134
"""
@@ -563,19 +563,13 @@ def validate_unions(schema, value):
563
563
return validate_union (schema .schema , value )
564
564
565
565
566
- class Schema (object ):
567
- """Wraps a validator schema into a object."""
568
-
569
- def __init__ (self , * schemas ):
570
- self .schema = all (* schemas )
566
+ class Schema (all ):
567
+ """
568
+ Wrapper class for :class:`all` with a validate method which raises :class:`PluginError` by default on error.
569
+ """
571
570
572
571
def validate (self , value , name = "result" , exception = PluginError ):
573
572
try :
574
- return validate (self . schema , value )
573
+ return validate (self , value )
575
574
except ValueError as err :
576
575
raise exception ("Unable to validate {0}: {1}" .format (name , err ))
577
-
578
-
579
- @validate .register (Schema )
580
- def validate_schema (schema , value ):
581
- return schema .validate (value , exception = ValueError )
0 commit comments