def _validate_isvalid_reference(self, isvalid_reference, field, value):
if '<STR_LIT>' in value:<EOL><INDENT>try:<EOL><INDENT>ref = crossref_api.works(ids=value['<STR_LIT>'])['<STR_LIT:message>']<EOL><DEDENT>except (HTTPError, habanero.RequestError):<EOL><INDENT>self._error(field, '<STR_LIT>')<EOL>return<EOL><DEDENT>except ConnectionError:<EOL><INDENT>warn('<STR_LIT>')<EOL>return<EOL><DEDENT>ref_container = ref.get('<STR_LIT>')[<NUM_LIT:0>]<EOL>container = value.get('<STR_LIT>')<EOL>if container is None or container != ref_container:<EOL><INDENT>self._error(field, '<STR_LIT>'.format(ref_container))<EOL><DEDENT>ref_year = ref.get('<STR_LIT>') or ref.get('<STR_LIT>')<EOL>ref_year = ref_year['<STR_LIT>'][<NUM_LIT:0>][<NUM_LIT:0>]<EOL>year = value.get('<STR_LIT>')<EOL>if year is None or year != ref_year:<EOL><INDENT>self._error(field, '<STR_LIT>'.format(ref_year))<EOL><DEDENT>ref_volume = ref.get('<STR_LIT>')<EOL>volume = value.get('<STR_LIT>')<EOL>if ref_volume is None:<EOL><INDENT>if volume is not None:<EOL><INDENT>self._error(field, '<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if volume is None or int(volume) != int(ref_volume):<EOL><INDENT>self._error(field, '<STR_LIT>'.format(ref_volume))<EOL><DEDENT><DEDENT>ref_pages = ref.get('<STR_LIT>')<EOL>pages = value.get('<STR_LIT>')<EOL>if ref_pages is None:<EOL><INDENT>if pages is not None:<EOL><INDENT>self._error(field, '<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if pages is None or pages != ref_pages:<EOL><INDENT>self._error(field, '<STR_LIT>'.format(ref_pages))<EOL><DEDENT><DEDENT>authors = value['<STR_LIT>'][:]<EOL>author_names = [a['<STR_LIT:name>'] for a in authors]<EOL>for author in ref['<STR_LIT>']:<EOL><INDENT>author_match = next(<EOL>(a for a in authors if<EOL>compare_name(author['<STR_LIT>'], author['<STR_LIT>'], a['<STR_LIT:name>'])<EOL>),<EOL>None<EOL>)<EOL>if author_match is None:<EOL><INDENT>self._error(field, '<STR_LIT>' +<EOL>'<STR_LIT:U+0020>'.join([author['<STR_LIT>'], author['<STR_LIT>']])<EOL>)<EOL><DEDENT>else:<EOL><INDENT>author_names.remove(author_match['<STR_LIT:name>'])<EOL>orcid = author.get('<STR_LIT>')<EOL>if orcid:<EOL><INDENT>orcid = orcid[orcid.rfind('<STR_LIT:/>') + <NUM_LIT:1>:]<EOL>if '<STR_LIT>' in author_match:<EOL><INDENT>if author_match['<STR_LIT>'] != orcid:<EOL><INDENT>self._error(<EOL>field, author_match['<STR_LIT:name>'] + '<STR_LIT>' +<EOL>'<STR_LIT>' +<EOL>orcid + '<STR_LIT>' + author_match['<STR_LIT>']<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>warn('<STR_LIT>' + orcid + '<STR_LIT>' + author_match['<STR_LIT:name>'])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if len(author_names) > <NUM_LIT:0>:<EOL><INDENT>self._error(field, '<STR_LIT>' +<EOL>'<STR_LIT:U+002CU+0020>'.join(author_names)<EOL>)<EOL><DEDENT><DEDENT>
Checks valid reference metadata using DOI (if present).

        Args:
            isvalid_reference (`bool`): flag from schema indicating reference to be checked.
            field (`str`): 'reference'
            value (`dict`): dictionary of reference metadata.

        The rule's arguments are validated against this schema:
            {'isvalid_reference': {'type': 'bool'}, 'field': {'type': 'str'},
             'value': {'type': 'dict'}}