UNPKG

765 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _default;
7
8function _default(action, {
9 checkPath = true,
10 checkAbortOnFail = true
11} = {}) {
12 // it's not even an object, you fail!
13 if (typeof action !== 'object') {
14 return `Invalid action object: ${JSON.stringify(action)}`;
15 }
16
17 const {
18 path,
19 abortOnFail
20 } = action;
21
22 if (checkPath && (typeof path !== 'string' || path.length === 0)) {
23 return `Invalid path "${path}"`;
24 } // abortOnFail is optional, but if it's provided it needs to be a Boolean
25
26
27 if (checkAbortOnFail && abortOnFail !== undefined && typeof abortOnFail !== 'boolean') {
28 return `Invalid value for abortOnFail (${abortOnFail} is not a Boolean)`;
29 }
30
31 return true;
32}
\No newline at end of file