serializers.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:munch-core 作者: crunchmail 项目源码 文件源码
def run_validation(self, data=[]):
        """
        We override the default `run_validation`, because the validation
        performed by validators and the `.validate()` method should
        be coerced into an error dictionary with a 'non_fields_error' key.
        """
        (is_empty_value, data) = self.validate_empty_values(data)
        if is_empty_value:
            return data

        try:
            value = self.to_internal_value(data)
            self.run_validators(value)
            value = self.validate(value)
            assert value is not None, '.validate() should return the validated data'  # noqa
        except (ValidationError, DjangoValidationError) as exc:
            # TODO: Must be 'recipient' instead of 'to' in v2
            raise ValidationError(
                detail={
                    'to': data['to'],
                    'errors': get_validation_error_detail(exc)})

        return value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号