(source)
| 125 | """ |
| 126 | |
| 127 | def build_dict(source): |
| 128 | errors_dict = {} |
| 129 | if isinstance(source, dict): |
| 130 | for field_name, error in source.items(): |
| 131 | errors_dict[field_name] = build_dict(error) |
| 132 | elif isinstance(source, ValidationError) and source.errors: |
| 133 | return build_dict(source.errors) |
| 134 | else: |
| 135 | return str(source) |
| 136 | |
| 137 | return errors_dict |
| 138 | |
| 139 | if not self.errors: |
| 140 | return {} |