code: def filter(self, u):
          
          if not isinstance(u, UniqueIdentity):
              raise ValueError("<u> is not an instance of UniqueIdentity")
  
          filtered = []
  
          for id_ in u.identities:
              email = None
              name = None
  
              if self.sources and id_.source.lower() not in self.sources:
                  continue
  
              if self._check_blacklist(id_):
                  continue
  
              if self.strict:
                  if self._check_pattern(self.email_pattern, id_.email):
                      email = id_.email.lower()
                  if self._check_pattern(self.name_pattern, id_.name):
                      name = id_.name.lower()
              else:
                  email = id_.email.lower() if id_.email else None
                  name = id_.name.lower() if id_.name else None
  
              if email or name:
                  fid = EmailNameIdentity(id_.id, id_.uuid,
                                          email, name)
                  filtered.append(fid)
  
          return filtered
docs: Filter the valid identities for this matcher.
  
          :param u: unique identity which stores the identities to filter
  
          :returns: a list of identities valid to work with this matcher.
  
          :raises ValueError: when the unique identity is not an instance
              of UniqueIdentity class