MCPcopy Create free account
hub / github.com/parse-community/parse-server / validateRequestComplexity

Method validateRequestComplexity

src/Config.js:687–715  ·  view source on GitHub ↗
(requestComplexity)

Source from the content-addressed store, hash-verified

685 }
686
687 static validateRequestComplexity(requestComplexity) {
688 if (requestComplexity == null) {
689 return;
690 }
691 if (typeof requestComplexity !== 'object' || Array.isArray(requestComplexity)) {
692 throw new Error('requestComplexity must be an object.');
693 }
694 const validKeys = Object.keys(RequestComplexityOptions);
695 for (const key of Object.keys(requestComplexity)) {
696 if (!validKeys.includes(key)) {
697 throw new Error(`requestComplexity contains unknown property '${key}'.`);
698 }
699 }
700 for (const key of validKeys) {
701 if (requestComplexity[key] !== undefined) {
702 const value = requestComplexity[key];
703 const def = RequestComplexityOptions[key];
704 if (typeof def.default === 'boolean') {
705 if (typeof value !== 'boolean') {
706 throw new Error(`requestComplexity.${key} must be a boolean.`);
707 }
708 } else if (!Number.isInteger(value) || (value < 1 && value !== -1)) {
709 throw new Error(`requestComplexity.${key} must be a positive integer or -1 to disable.`);
710 }
711 } else {
712 requestComplexity[key] = RequestComplexityOptions[key].default;
713 }
714 }
715 }
716
717 static validateInstallation(installation) {
718 if (installation === undefined) {

Callers 1

validateOptionsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected