Skip to content

v.match is not a function #735

Description

@MrShadow50

The function below is fixed and merged in the v5.x branch but wasn't released for loopback3. Is there a specific version which support loopback3 and have this fix.

function isObjectIDProperty(modelCtor, propDef, value, options) {
  if (!propDef) return false;

  if ((typeof value === 'string' && value.match(ObjectIdValueRegex)) ||
    (Array.isArray(value) && value.every((v) => v.match(ObjectIdValueRegex)))) {
    if (isStoredAsObjectID(propDef)) return true;
    else return !isStrictObjectIDCoercionEnabled(modelCtor, options);
  } else if (value instanceof mongodb.ObjectID) {
    return true;
  } else {
    return false;
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions