(request, functionName, auth)
| 719 | return error; |
| 720 | } |
| 721 | export function maybeRunValidator(request, functionName, auth) { |
| 722 | const theValidator = getValidator(functionName, Parse.applicationId); |
| 723 | if (!theValidator) { |
| 724 | return; |
| 725 | } |
| 726 | if (typeof theValidator === 'object' && theValidator.skipWithMasterKey && request.master) { |
| 727 | request.skipWithMasterKey = true; |
| 728 | } |
| 729 | return new Promise((resolve, reject) => { |
| 730 | return Promise.resolve() |
| 731 | .then(() => { |
| 732 | return typeof theValidator === 'object' |
| 733 | ? builtInTriggerValidator(theValidator, request, auth) |
| 734 | : theValidator(request); |
| 735 | }) |
| 736 | .then(() => { |
| 737 | resolve(); |
| 738 | }) |
| 739 | .catch(e => { |
| 740 | const error = resolveError(e, { |
| 741 | code: Parse.Error.VALIDATION_ERROR, |
| 742 | message: 'Validation failed.', |
| 743 | }); |
| 744 | reject(error); |
| 745 | }); |
| 746 | }); |
| 747 | } |
| 748 | async function builtInTriggerValidator(options, request, auth) { |
| 749 | if (request.master && !options.validateMasterKey) { |
| 750 | return; |
no test coverage detected