MCPcopy
hub / github.com/ampproject/amphtml / validateData

Function validateData

3p/3p.js:212–233  ·  view source on GitHub ↗
(data, mandatoryFields, opt_optionalFields)

Source from the content-addressed store, hash-verified

210 * @param {Array<string>=} opt_optionalFields
211 */
212export function validateData(data, mandatoryFields, opt_optionalFields) {
213 let allowedFields = opt_optionalFields || [];
214 for (let i = 0; i < mandatoryFields.length; i++) {
215 const field = mandatoryFields[i];
216 if (Array.isArray(field)) {
217 validateExactlyOne(data, field);
218 allowedFields = allowedFields.concat(field);
219 } else {
220 userAssert(
221 // Allow zero values for height, width etc.
222 data[field] != null,
223 'Missing attribute for %s: %s.',
224 data.type,
225 field
226 );
227 allowedFields.push(field);
228 }
229 }
230 if (opt_optionalFields) {
231 validateAllowedFields(data, allowedFields);
232 }
233}
234
235/**
236 * Throws an exception if data does not contains exactly one field

Callers 15

test-3p.jsFile · 0.90
myoffrzFunction · 0.90
adopFunction · 0.90
sunmediaFunction · 0.90
adreactorFunction · 0.90
videointelligenceFunction · 0.90
fusionFunction · 0.90
aduptechFunction · 0.90
yektanetFunction · 0.90
rubiconFunction · 0.90
kixerFunction · 0.90
smartclipFunction · 0.90

Calls 5

userAssertFunction · 0.90
validateExactlyOneFunction · 0.85
validateAllowedFieldsFunction · 0.85
concatMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected