UNPKG

@react-native-firebase/analytics

Version:

React Native Firebase - The analytics module provides out of the box support with Google Analytics for Firebase. Integration with the Android & iOS allows for in-depth analytical insight reporting, such as device information, location, user actions and mo

48 lines (46 loc) 1.63 kB
"use strict"; /* * Copyright (c) 2016-present Invertase Limited & Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this library except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { isUndefined } from '@react-native-firebase/app/dist/module/common/validate'; import { create } from 'superstruct'; export const validateStruct = (value = {}, struct, prefix = '') => { // skip superstruct create in release for performance reasons if (!__DEV__) { return value; } try { return create(value, struct); } catch (e) { const { path, message } = e; const key = path[0]; if (message === undefined) { throw new Error(`${prefix} unknown property '${key}'.`); } e.message = `${prefix} ${message}`; throw e; } }; export const validateCompound = (source = {}, a, b, prefix = '') => { const sourceA = source[a]; const sourceB = source[b]; if (isUndefined(sourceA) && !isUndefined(sourceB) || !isUndefined(sourceA) && isUndefined(sourceB)) { throw new Error(`${prefix} if you supply the '${a}' parameter, you must also supply the '${b}' parameter.`); } }; //# sourceMappingURL=struct.js.map