UNPKG

react-native-google-mobile-ads

Version:

React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.

68 lines (64 loc) 3.26 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 { isPropertySet, isArray, isBoolean, isObject } from './common'; import { MaxAdContentRating } from './MaxAdContentRating'; import { AgeRestrictedTreatment } from './types/AgeRestrictedTreatment'; export function validateAdRequestConfiguration(requestConfiguration) { const out = {}; if (!isObject(requestConfiguration)) { throw new Error("'requestConfiguration' expected an object value"); } if (requestConfiguration.maxAdContentRating) { if (!Object.values(MaxAdContentRating).includes(requestConfiguration.maxAdContentRating)) { throw new Error(`'requestConfiguration.maxAdContentRating' expected one of ${Object.values(MaxAdContentRating).join(', ')}`); } out.maxAdContentRating = requestConfiguration.maxAdContentRating; } if (requestConfiguration.ageRestrictedTreatment) { if (!Object.values(AgeRestrictedTreatment).includes(requestConfiguration.ageRestrictedTreatment)) { throw new Error(`'requestConfiguration.ageRestrictedTreatment' expected one of ${Object.values(AgeRestrictedTreatment).join(', ')}`); } out.ageRestrictedTreatment = requestConfiguration.ageRestrictedTreatment; } if (isPropertySet(requestConfiguration, 'tagForChildDirectedTreatment')) { // eslint-disable-next-line @typescript-eslint/no-deprecated const tagForChildDirectedTreatment = requestConfiguration.tagForChildDirectedTreatment; if (!isBoolean(tagForChildDirectedTreatment)) { throw new Error("'requestConfiguration.tagForChildDirectedTreatment' expected a boolean value"); } // eslint-disable-next-line @typescript-eslint/no-deprecated out.tagForChildDirectedTreatment = requestConfiguration.tagForChildDirectedTreatment; } if (isPropertySet(requestConfiguration, 'tagForUnderAgeOfConsent')) { // eslint-disable-next-line @typescript-eslint/no-deprecated const tagForUnderAgeOfConsent = requestConfiguration.tagForUnderAgeOfConsent; if (!isBoolean(tagForUnderAgeOfConsent)) { throw new Error("'requestConfiguration.tagForUnderAgeOfConsent' expected a boolean value"); } // eslint-disable-next-line @typescript-eslint/no-deprecated out.tagForUnderAgeOfConsent = requestConfiguration.tagForUnderAgeOfConsent; } if (isPropertySet(requestConfiguration, 'testDeviceIdentifiers')) { if (!isArray(requestConfiguration.testDeviceIdentifiers)) { throw new Error("'requestConfiguration.testDeviceIdentifiers' expected an array value"); } out.testDeviceIdentifiers = requestConfiguration.testDeviceIdentifiers; } return out; } //# sourceMappingURL=validateAdRequestConfiguration.js.map