How to use the @react-native-firebase/app/lib/common.isNumber 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 / analytics / lib / index.js View on Github external
throw new Error(
        `firebase.analytics().logEvent(*) 'name' invalid event name '${name}'. Names should contain 1 to 32 alphanumeric characters or underscores.`,
      );
    }

    // maximum number of allowed params check
    if (params && Object.keys(params).length > 25) {
      throw new Error(
        "firebase.analytics().logEvent(_, *) 'params' maximum number of parameters exceeded (25).",
      );
    }

    const entries = Object.entries(params);
    for (let i = 0; i < entries.length; i++) {
      const [key, value] = entries[i];
      if (!isString(value) && !isNumber(value) && !isBoolean(value)) {
        throw new Error(
          `firebase.analytics().logEvent(_, *) 'params' value for parameter '${key}' is invalid, expected a string or number value.`,
        );
      }
    }

    return this.native.logEvent(name, params);
  }
github invertase / react-native-firebase / packages / perf / lib / Trace.js View on Github external
putMetric(metricName, value) {
    // TODO(VALIDATION): metricName: no leading or trailing whitespace, no leading underscore '_' character, max length is 32 characters
    // TODO(VALIDATION): value: >= 0
    if (!isString(metricName)) {
      throw new Error("firebase.perf.Trace.putMetric(*, _) 'metricName' must be a string.");
    }

    if (!isNumber(value)) {
      throw new Error("firebase.perf.Trace.putMetric(_, *) 'value' must be a number.");
    }

    this._metrics[metricName] = value;
  }
github invertase / react-native-firebase / packages / firestore / lib / FirestoreQueryModifiers.js View on Github external
isValidLimit(limit) {
    return !isNumber(limit) || Math.floor(limit) !== limit || limit <= 0;
  }
github invertase / react-native-firebase / packages / ml-natural-language / lib / validateTextMessage.js View on Github external
timestamp: Date.now(),
    isLocalUser: true,
  };

  if (!isString(textMessage.text)) {
    throw new Error("'textMessage.text' expected a string value");
  }

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

  out.text = textMessage.text;

  if (hasOwnProperty(textMessage, 'timestamp')) {
    if (!isNumber(textMessage.timestamp)) {
      throw new Error("'textMessage.timestamp' expected number value (milliseconds)");
    }

    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(
github invertase / react-native-firebase / packages / firestore / lib / FirestoreFieldValue.js View on Github external
static increment(n) {
    if (!isNumber(n)) {
      throw new Error("firebase.firestore.FieldValue.increment(*) 'n' expected a number value.");
    }

    return new FirestoreFieldValue(true, TypeFieldValueIncrement, n);
  }
github invertase / react-native-firebase / packages / analytics / lib / index.js View on Github external
setMinimumSessionDuration(milliseconds = 10000) {
    if (!isNumber(milliseconds)) {
      throw new Error(
        "firebase.analytics().setMinimumSessionDuration(*) 'milliseconds' expected a number value.",
      );
    }

    if (milliseconds < 0) {
      throw new Error(
        "firebase.analytics().setMinimumSessionDuration(*) 'milliseconds' expected a positive number value.",
      );
    }

    return this.native.setMinimumSessionDuration(milliseconds);
  }
github invertase / react-native-firebase / packages / firestore / lib / FirestoreGeoPoint.js View on Github external
constructor(latitude, longitude) {
    if (isUndefined(latitude) || isUndefined(longitude)) {
      throw new Error(
        'firebase.firestore.GeoPoint constructor expected latitude and longitude values.',
      );
    }

    if (!isNumber(latitude)) {
      throw new Error("firebase.firestore.GeoPoint 'latitude' must be a number value.");
    }

    if (!isNumber(longitude)) {
      throw new Error("firebase.firestore.GeoPoint 'longitude' must be a number value.");
    }

    if (!isFinite(latitude) || latitude < -90 || latitude > 90) {
      throw new Error(
        `firebase.firestore.GeoPoint 'longitude' must be a number between -90 and 90, but was: ${latitude}.`,
      );
    }

    if (!isFinite(longitude) || longitude < -180 || longitude > 180) {
      throw new Error(
        `firebase.firestore.GeoPoint 'longitude' must be a number between -180 and 180, but was: ${longitude}.`,
github invertase / react-native-firebase / packages / invites / lib / Invite.js View on Github external
setAndroidMinimumVersionCode(androidMinimumVersionCode) {
    if (!isNumber(androidMinimumVersionCode)) {
      throw new Error(
        "firebase.invites.Invite.setAndroidMinimumVersionCode(*) 'androidMinimumVersionCode' must be a number value.",
      );
    }

    this._androidMinimumVersionCode = androidMinimumVersionCode;
    return this;
  }
github invertase / react-native-firebase / packages / database / lib / DatabaseQueryModifiers.js View on Github external
isValidPriority(priority) {
    return isNumber(priority) || isString(priority) || isNull(priority);
  }
github invertase / react-native-firebase / packages / ml-natural-language / lib / index.js View on Github external
function validateIdentifyLanguageArgs(text, options, methodName) {
  if (!isString(text)) {
    throw new Error(
      `firebase.naturalLanguage().${methodName}(*, _) 'text' must be a string value.`,
    );
  }

  if (!isObject(options)) {
    throw new Error(
      `firebase.naturalLanguage().${methodName}(_, *) 'options' must be an object or undefined.`,
    );
  }

  if (
    !isUndefined(options.confidenceThreshold) &&
    (!isNumber(options.confidenceThreshold) ||
      options.confidenceThreshold < 0 ||
      options.confidenceThreshold > 1)
  ) {
    throw new Error(
      `firebase.naturalLanguage().${methodName}(_, *) 'options.confidenceThreshold' must be a float value between 0 and 1.`,
    );
  }
}

@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 27 days ago

Package Health Score

98 / 100
Full package analysis