def validate(self, data): scan_type = data.get("scan_type") file = data.get("file") if not file and requires_file(scan_type): raise serializers.ValidationError( 'Uploading a Report File is required for {}'.format(scan_type)) return data
def validate(self, data): scan_type = data.get("scan_type") file = data.get("file") if not file and requires_file(scan_type): raise serializers.ValidationError( 'Uploading a Report File is required for {}'.format(scan_type)) if file and is_scan_file_too_large(file): raise serializers.ValidationError( 'Report file is too large. Maximum supported size is {} MB'. format(settings.SCAN_FILE_MAX_SIZE)) return data