code: def _validate_user(self, user):
          
          # All users allowed
          if self._show_all_users:
              return
  
          # User specifically allowed
          if user.id in self._allowed_user_ids:
              return
  
          # User allowed by group membership
          user_member_group_ids = set([g['id'] for g in user._raw['groups']])
          if user_member_group_ids & self._allowed_member_ids:
              return
  
          raise ValidationError(
              self.record,
              'User `{}` is not a valid selection for field `{}`'.format(
                  user,
                  self.name
              )
          )
docs: Validate a User instance against allowed user IDs or membership in a group