'Validates the state of this xblock instance.'

def validate(self):

    _ = self.runtime.service(self, 'i18n').ugettext
    validation = super(LmsBlockMixin, self).validate()
    has_invalid_user_partitions = False
    has_invalid_groups = False
    block_is_unit = is_unit(self)
    for (user_partition_id, group_ids) in self.group_access.iteritems():
        try:
            user_partition = self._get_user_partition(user_partition_id)
        except NoSuchUserPartitionError:
            has_invalid_user_partitions = True
        else:
            if user_partition.active:
                for group_id in group_ids:
                    try:
                        user_partition.get_group(group_id)
                    except NoSuchUserPartitionGroupError:
                        has_invalid_groups = True
    if has_invalid_user_partitions:
        validation.add(ValidationMessage(ValidationMessage.ERROR, (INVALID_USER_PARTITION_VALIDATION_UNIT if block_is_unit else INVALID_USER_PARTITION_VALIDATION_COMPONENT)))
    if has_invalid_groups:
        validation.add(ValidationMessage(ValidationMessage.ERROR, (INVALID_USER_PARTITION_GROUP_VALIDATION_UNIT if block_is_unit else INVALID_USER_PARTITION_GROUP_VALIDATION_COMPONENT)))
    if self._has_nonsensical_access_settings():
        validation.add(ValidationMessage(ValidationMessage.ERROR, NONSENSICAL_ACCESS_RESTRICTION))
    return validation
