How to use the @react-native-firebase/app/lib/common.hasOwnProperty function in @react-native-firebase/app

To help you get started, we’ve selected a few @react-native-firebase/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github invertase / react-native-firebase / packages / perf / lib / MetricWithAttributes.js View on Github external
putAttribute(attribute, value) {
    // TODO(VALIDATION): attribute: no leading or trailing whitespace, no leading underscore '_'
    if (!isString(attribute) || attribute.length > 40) {
      throw new Error(
        "firebase.perf.*.putAttribute(*, _) 'attribute' must be a string with a maximum length of 40 characters.",
      );
    }

    if (!isString(value) || value.length > 100) {
      throw new Error(
        "firebase.perf.*.putAttribute(_, *) 'value' must be a string with a maximum length of 100 characters.",
      );
    }

    if (!hasOwnProperty(this._attributes, attribute) && Object.keys(this._attributes).length > 4) {
      throw new Error(
        'firebase.perf.*.putAttribute(_, _) the maximum number of attributes (5) has been reached.',
      );
    }

    this._attributes[attribute] = value;
  }
}
github invertase / react-native-firebase / packages / firestore / lib / utils / index.js View on Github external
export function parseSetOptions(options) {
  const out = {};

  if (isUndefined(options)) {
    return out;
  }

  if (!isObject(options)) {
    throw new Error("'options' must be an object.");
  }

  if (hasOwnProperty(options, 'merge') && hasOwnProperty(options, 'mergeFields')) {
    throw new Error("'options' must not contain both 'merge' & 'mergeFields'.");
  }

  if (!isUndefined(options.merge)) {
    if (!isBoolean(options.merge)) {
      throw new Error("'options.merge' must be a boolean value.");
    }

    out.merge = true;
  }

  if (!isUndefined(options.mergeFields)) {
    if (!isArray(options.mergeFields)) {
      throw new Error("'options.mergeFields' must be an array.");
    }
github invertase / react-native-firebase / packages / messaging / lib / remoteMessageOptions.js View on Github external
out.to = `${messagingSenderId}@fcm.googleapis.com`;
  } else if (!isString(remoteMessage.to)) {
    throw new Error("'remoteMessage.to' expected a string value");
  } else {
    out.to = remoteMessage.to;
  }

  if (!remoteMessage.messageId) {
    out.messageId = generateFirestoreId();
  } else if (!isString(remoteMessage.messageId)) {
    throw new Error("'remoteMessage.messageId' expected a string value");
  } else {
    out.messageId = remoteMessage.messageId;
  }

  if (!hasOwnProperty(remoteMessage, 'ttl')) {
    out.ttl = 3600;
  } else {
    if (!isNumber(remoteMessage.ttl)) {
      throw new Error("'remoteMessage.ttl' expected a number value");
    }
    if (remoteMessage.ttl < 0 || !isInteger(remoteMessage.ttl)) {
      throw new Error("'remoteMessage.ttl' expected a positive integer value");
    }
    out.ttl = remoteMessage.ttl;
  }

  if (!remoteMessage.data) {
    out.data = {};
  } else if (!isObject(remoteMessage.data)) {
    throw new Error("'remoteMessage.data' expected an object value");
  } else {
github invertase / react-native-firebase / packages / admob / lib / validateAdRequestOptions.js View on Github external
if (latitude < -90 || latitude > 90) {
      throw new Error(
        `'options.location' latitude value must be a number between -90 and 90, but was: ${latitude}`,
      );
    }

    if (longitude < -180 || longitude > 180) {
      throw new Error(
        `'options.location' longitude value must be a number between -180 and 180, but was: ${latitude}`,
      );
    }

    out.location = [latitude, longitude];
  }

  if (hasOwnProperty(options, 'locationAccuracy')) {
    if (!isNumber(options.locationAccuracy)) {
      throw new Error("'options.locationAccuracy' expected a number value.");
    }

    if (options.locationAccuracy < 0) {
      throw new Error("'options.locationAccuracy' expected a number greater than 0.");
    }

    out.locationAccuracy = options.locationAccuracy;
  } else {
    out.locationAccuracy = 5;
  }

  if (options.requestAgent) {
    if (!isString(options.requestAgent)) {
      throw new Error("'options.requestAgent' expected a string value");
github invertase / react-native-firebase / packages / ml-vision / lib / visionFaceDetectorOptions.js View on Github external
}

  if (faceDetectorOptions.landmarkMode) {
    if (
      faceDetectorOptions.landmarkMode !== VisionFaceDetectorLandmarkMode.NO_LANDMARKS &&
      faceDetectorOptions.landmarkMode !== VisionFaceDetectorLandmarkMode.ALL_LANDMARKS
    ) {
      throw new Error(
        "'faceDetectorOptions.landmarkMode' invalid landmark mode. Expected VisionFaceDetectorLandmarkMode.NO_LANDMARKS or VisionFaceDetectorLandmarkMode.ALL_LANDMARKS.",
      );
    }

    out.landmarkMode = faceDetectorOptions.landmarkMode;
  }

  if (hasOwnProperty(faceDetectorOptions, 'minFaceSize')) {
    if (!isNumber(faceDetectorOptions.minFaceSize)) {
      throw new Error("'faceDetectorOptions.minFaceSize' expected a number value between 0 & 1.");
    }

    if (faceDetectorOptions.minFaceSize < 0 || faceDetectorOptions.minFaceSize > 1) {
      throw new Error("'faceDetectorOptions.minFaceSize' expected value to be between 0 & 1.");
    }

    out.minFaceSize = faceDetectorOptions.minFaceSize;
  }

  if (faceDetectorOptions.performanceMode) {
    if (
      faceDetectorOptions.performanceMode !== VisionFaceDetectorPerformanceMode.FAST &&
      faceDetectorOptions.performanceMode !== VisionFaceDetectorPerformanceMode.ACCURATE
    ) {
github invertase / react-native-firebase / packages / ml-vision / lib / visionCloudImageLabelerOptions.js View on Github external
export default function visionCloudImageLabelerOptions(cloudImageLabelerOptions) {
  const out = {
    enforceCertFingerprintMatch: false,
    confidenceThreshold: 0.5,
  };

  if (isUndefined(cloudImageLabelerOptions)) {
    return out;
  }

  if (!isObject(cloudImageLabelerOptions)) {
    throw new Error("'cloudImageLabelerOptions' expected an object value.");
  }

  if (hasOwnProperty(cloudImageLabelerOptions, 'enforceCertFingerprintMatch')) {
    if (!isBoolean(cloudImageLabelerOptions.enforceCertFingerprintMatch)) {
      throw new Error(
        "'cloudImageLabelerOptions.enforceCertFingerprintMatch' expected a boolean value.",
      );
    }

    out.enforceCertFingerprintMatch = cloudImageLabelerOptions.enforceCertFingerprintMatch;
  }

  if (hasOwnProperty(cloudImageLabelerOptions, 'apiKeyOverride')) {
    if (!isString(cloudImageLabelerOptions.apiKeyOverride)) {
      throw new Error("'cloudImageLabelerOptions.apiKeyOverride' expected a string value.");
    }

    out.apiKeyOverride = cloudImageLabelerOptions.apiKeyOverride;
  }
github invertase / react-native-firebase / packages / admob / lib / validateAdRequestConfiguration.js View on Github external
if (requestConfiguration.maxAdContentRating) {
    if (
      requestConfiguration.maxAdContentRating !== MaxAdContentRating.G &&
      requestConfiguration.maxAdContentRating !== MaxAdContentRating.PG &&
      requestConfiguration.maxAdContentRating !== MaxAdContentRating.T &&
      requestConfiguration.maxAdContentRating !== MaxAdContentRating.MA
    ) {
      throw new Error(
        "'requestConfiguration.maxAdContentRating' expected on of MaxAdContentRating.G, MaxAdContentRating.PG, MaxAdContentRating.T or MaxAdContentRating.MA",
      );
    }

    out.maxAdContentRating = requestConfiguration.maxAdContentRating;
  }

  if (hasOwnProperty(requestConfiguration, 'tagForChildDirectedTreatment')) {
    if (!isBoolean(requestConfiguration.tagForChildDirectedTreatment)) {
      throw new Error(
        "'requestConfiguration.tagForChildDirectedTreatment' expected a boolean value",
      );
    }

    out.tagForChildDirectedTreatment = requestConfiguration.tagForChildDirectedTreatment;
  }

  if (hasOwnProperty(requestConfiguration, 'tagForUnderAgeOfConsent')) {
    if (!isBoolean(requestConfiguration.tagForUnderAgeOfConsent)) {
      throw new Error("'requestConfiguration.tagForUnderAgeOfConsent' expected a boolean value");
    }

    out.tagForUnderAgeOfConsent = requestConfiguration.tagForUnderAgeOfConsent;
  }
github invertase / react-native-firebase / packages / ml-vision / lib / visionCloudDocumentTextRecognizerOptions.js View on Github external
if (!isObject(cloudDocumentTextRecognizerOptions)) {
    throw new Error("'cloudDocumentTextRecognizerOptions' expected an object value.");
  }

  if (hasOwnProperty(cloudDocumentTextRecognizerOptions, 'enforceCertFingerprintMatch')) {
    if (!isBoolean(cloudDocumentTextRecognizerOptions.enforceCertFingerprintMatch)) {
      throw new Error(
        "'cloudDocumentTextRecognizerOptions.enforceCertFingerprintMatch' expected a boolean value.",
      );
    }

    out.enforceCertFingerprintMatch =
      cloudDocumentTextRecognizerOptions.enforceCertFingerprintMatch;
  }

  if (hasOwnProperty(cloudDocumentTextRecognizerOptions, 'apiKeyOverride')) {
    if (!isString(cloudDocumentTextRecognizerOptions.apiKeyOverride)) {
      throw new Error(
        "'cloudDocumentTextRecognizerOptions.apiKeyOverride' expected a string value.",
      );
    }

    out.apiKeyOverride = cloudDocumentTextRecognizerOptions.apiKeyOverride;
  }

  if (cloudDocumentTextRecognizerOptions.languageHints) {
    if (
      !isArray(cloudDocumentTextRecognizerOptions.languageHints) ||
      !cloudDocumentTextRecognizerOptions.languageHints.length ||
      !isString(cloudDocumentTextRecognizerOptions.languageHints[0])
    ) {
      throw new Error(
github invertase / react-native-firebase / packages / admob / lib / AdsConsent.js View on Github external
}

    if (!isValidUrl(options.privacyPolicy)) {
      throw new Error(
        "firebase.admob.AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.",
      );
    }

    if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) {
      throw new Error(
        "firebase.admob.AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.",
      );
    }

    if (
      hasOwnProperty(options, 'withNonPersonalizedAds') &&
      !isBoolean(options.withNonPersonalizedAds)
    ) {
      throw new Error(
        "firebase.admob.AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.",
      );
    }

    if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) {
      throw new Error(
        "firebase.admob.AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.",
      );
    }

    return native.showForm(options);
  },
github invertase / react-native-firebase / packages / ml-natural-language / lib / validateTextMessage.js View on Github external
out.timestamp = textMessage.timestamp;
  }

  if (hasOwnProperty(textMessage, 'isLocalUser')) {
    if (!isBoolean(textMessage.isLocalUser)) {
      throw new Error("'textMessage.isLocalUser' expected boolean value");
    }

    out.isLocalUser = textMessage.isLocalUser;
  }

  if (out.isLocalUser && hasOwnProperty(textMessage, 'userId')) {
    throw new Error(
      "'textMessage.userId' expected 'textMessage.isLocalUser' to be false when setting a user ID.",
    );
  } else if (!out.isLocalUser && !hasOwnProperty(textMessage, 'userId')) {
    throw new Error("'textMessage.userId' expected a string value");
  } else if (!out.isLocalUser && hasOwnProperty(textMessage, 'userId')) {
    if (!isString(textMessage.userId)) {
      throw new Error("'textMessage.userId' expected a string value");
    }

    if (textMessage.userId.length === 0) {
      throw new Error("'textMessage.userId' expected string value to not be empty");
    }

    out.userId = textMessage.userId;
  }

  return out;
}

@react-native-firebase/app

A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto

Apache-2.0
Latest version published 1 day ago

Package Health Score

98 / 100
Full package analysis