from schematics.exceptions import ConversionError
from schematics.undefined import Undefined
from schematics.types import BaseType
def check_required(self, value, context):
if self.required and value is Undefined:
if self.name is None or context and not context.partial:
raise ConversionError(self.messages['required'])
BaseType.check_required = check_required
猴子修补
BaseType
似乎是实现这一目标的唯一方法。在相关问题 更多 >
编程相关推荐