MCPcopy Index your code
hub / github.com/parse-community/parse-server / validateOptions

Function validateOptions

src/triggers.js:781–807  ·  view source on GitHub ↗
(opt, key, val)

Source from the content-addressed store, hash-verified

779 };
780
781 const validateOptions = async (opt, key, val) => {
782 let opts = opt.options;
783 if (typeof opts === 'function') {
784 try {
785 const result = await opts(val);
786 if (!result && result != null) {
787 throw opt.error || `Validation failed. Invalid value for ${key}.`;
788 }
789 } catch (e) {
790 if (!e) {
791 throw opt.error || `Validation failed. Invalid value for ${key}.`;
792 }
793
794 throw opt.error || e.message || e;
795 }
796 return;
797 }
798 if (!Array.isArray(opts)) {
799 opts = [opt.options];
800 }
801
802 if (!opts.includes(val)) {
803 throw (
804 opt.error || `Validation failed. Invalid option for ${key}. Expected: ${opts.join(', ')}`
805 );
806 }
807 };
808
809 const getType = fn => {
810 const match = fn && fn.toString().match(/^\s*function (\w+)/);

Callers 1

builtInTriggerValidatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected