'Check that the invariant holds for the given value.
:param value: Value to check invariant for.
:returns: Pair of whether the invariant holds, and a message describing
why it doesn\'t.
:rtype: `tuple` of `bool` and `str`'

def __call__(self, value):

    tag = getattr(value, self.tag_attribute)
    if (tag not in self._allowed_tags):
        return (False, 'can    only    be    in    {tag_name}s    {tags}.'.format(tag_name=self.tag_attribute, tags=',    '.join(map('`{0.name}`'.format, self._allowed_tags))))
    for attribute in self.attributes_for_tag[tag]:
        if (not hasattr(value, attribute)):
            return (False, '`{attr}`    must    be    specified    in    {tag_name}    `{tag}`'.format(attr=attribute, tag_name=self.tag_attribute, tag=tag.name))
    for attribute in (self._all_attributes - self.attributes_for_tag[tag]):
        if hasattr(value, attribute):
            return (False, "`{attr}`    can't    be    specified    in    {tag_name}    `{tag}`".format(attr=attribute, tag_name=self.tag_attribute, tag=tag.name))
    return (True, '')
