Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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;
}
isValidLimit(limit) {
return !isNumber(limit) || Math.floor(limit) !== limit || limit <= 0;
}
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(
static increment(n) {
if (!isNumber(n)) {
throw new Error("firebase.firestore.FieldValue.increment(*) 'n' expected a number value.");
}
return new FirestoreFieldValue(true, TypeFieldValueIncrement, n);
}
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);
}
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}.`,
setAndroidMinimumVersionCode(androidMinimumVersionCode) {
if (!isNumber(androidMinimumVersionCode)) {
throw new Error(
"firebase.invites.Invite.setAndroidMinimumVersionCode(*) 'androidMinimumVersionCode' must be a number value.",
);
}
this._androidMinimumVersionCode = androidMinimumVersionCode;
return this;
}
isValidPriority(priority) {
return isNumber(priority) || isString(priority) || isNull(priority);
}
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.`,
);
}
}