|
a/Ming/ming/schema.py |
|
b/Ming/ming/schema.py |
|
... |
|
... |
150 |
return self._validate(value, **kw)
|
150 |
return self._validate(value, **kw)
|
151 |
|
151 |
|
152 |
def _validate(self, value, **kw): return value
|
152 |
def _validate(self, value, **kw): return value
|
153 |
|
153 |
|
154 |
class Anything(FancySchemaItem):
|
154 |
class Anything(FancySchemaItem):
|
155 |
'Anything goes - always passes validation unchanged'
|
155 |
'Anything goes - always passes validation unchanged except dict=>Object'
|
156 |
pass
|
156 |
|
|
|
157 |
def validate(self, value, **kw):
|
|
|
158 |
from . import base
|
|
|
159 |
if isinstance(value, dict) and not isinstance(value, base.Object):
|
|
|
160 |
return base.Object(value)
|
|
|
161 |
return value
|
157 |
|
162 |
|
158 |
class Object(FancySchemaItem):
|
163 |
class Object(FancySchemaItem):
|
159 |
'''Used for dict-like validation. Also ensures that the incoming object does
|
164 |
'''Used for dict-like validation. Also ensures that the incoming object does
|
160 |
not have any extra keys AND performs polymorphic validation (which means that
|
165 |
not have any extra keys AND performs polymorphic validation (which means that
|
161 |
ParentClass._validate(...) sometimes will return an instance of ChildClass).
|
166 |
ParentClass._validate(...) sometimes will return an instance of ChildClass).
|