function _filterInvalidIds(ids, foreignSchemaType, skipInvalidIds) {
  ids = ids.filter(v => !(v instanceof SkipPopulateValue));
  if (!skipInvalidIds) {
    return ids;
  }
  return ids.filter(id => {
    try {
      foreignSchemaType.cast(id);
      return true;
    } catch (err) {
      return false;
    }
  });
}
Optionally filter out invalid ids that don't conform to foreign field's schema
to avoid cast errors (gh-7706)
@param {Array} ids
@param {SchemaType} foreignSchemaType
@param {Boolean} [skipInvalidIds]
@api private