def METHOD_NAME(self, data, **kwargs):
    """Gets the host_id from parent attribute. Pops it and tries to
    get a Host with that id in the corresponding workspace.
    """
    host_id = data.pop('host_id', None)
    if self.context['updating']:
        if host_id is None:
            # Partial update?
            return data
        if 'object' in self.context:
            if host_id != self.context['object'].parent.id:
                raise ValidationError('Can\'t change service parent.')
        else:
            if any(host_id != obj.parent.id for obj in self.context['objects']):
                raise ValidationError('Can\'t change service parent.')
    else:
        if not host_id:
            raise ValidationError('Parent id is required when creating a service.')
        try:
            data['host'] = Host.query.join(Workspace).filter(
                Workspace.name == self.context['workspace_name'],
                Host.id == host_id
            ).one()
        except NoResultFound as e:
            raise ValidationError(f'Host with id {host_id} not found') from e
    return data