'Validates the state of this Library Content Module Instance. This
is the override of the general XBlock method, and it will also ask
its superclass to validate.'

def validate(self):

    validation = super(LibraryContentDescriptor, self).validate()
    if (not isinstance(validation, StudioValidation)):
        validation = StudioValidation.copy(validation)
    library_tools = self.runtime.service(self, 'library_tools')
    if (not (library_tools and library_tools.can_use_library_content(self))):
        validation.set_summary(StudioValidationMessage(StudioValidationMessage.ERROR, _(u'This    course    does    not    support    content    libraries.    Contact    your    system    administrator    for    more    information.')))
        return validation
    if (not self.source_library_id):
        validation.set_summary(StudioValidationMessage(StudioValidationMessage.NOT_CONFIGURED, _(u'A    library    has    not    yet    been    selected.'), action_class='edit-button', action_label=_(u'Select    a    Library.')))
        return validation
    lib_tools = self.runtime.service(self, 'library_tools')
    self._validate_library_version(validation, lib_tools, self.source_library_version, self.source_library_key)
    matching_children_count = len(self.children)
    if (matching_children_count == 0):
        self._set_validation_error_if_empty(validation, StudioValidationMessage(StudioValidationMessage.WARNING, _(u'There    are    no    matching    problem    types    in    the    specified    libraries.'), action_class='edit-button', action_label=_(u'Select    another    problem    type.')))
    if (matching_children_count < self.max_count):
        self._set_validation_error_if_empty(validation, StudioValidationMessage(StudioValidationMessage.WARNING, (ngettext(u'The    specified    library    is    configured    to    fetch    {count}    problem,    ', u'The    specified    library    is    configured    to    fetch    {count}    problems,    ', self.max_count) + ngettext(u'but    there    is    only    {actual}    matching    problem.', u'but    there    are    only    {actual}    matching    problems.', matching_children_count)).format(count=self.max_count, actual=matching_children_count), action_class='edit-button', action_label=_(u'Edit    the    library    configuration.')))
    return validation
