diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-10-26 19:05:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-10-26 19:36:59 -0300 |
commit | 5f740046562c85ab4e00063037ddf3af5a545279 (patch) | |
tree | 3581813e1af6f3446a3986d9381093bd1ea0cb20 /src/data | |
parent | ecac8276182436897dffff02aaf1a7d268738cba (diff) |
data, test: withResultOfAvailabilityCheck: index mode
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/composite/control-flow/inputAvailabilityCheckMode.js | 2 | ||||
-rw-r--r-- | src/data/composite/control-flow/withResultOfAvailabilityCheck.js | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/data/composite/control-flow/inputAvailabilityCheckMode.js b/src/data/composite/control-flow/inputAvailabilityCheckMode.js index d74a1149..8008fdeb 100644 --- a/src/data/composite/control-flow/inputAvailabilityCheckMode.js +++ b/src/data/composite/control-flow/inputAvailabilityCheckMode.js @@ -3,7 +3,7 @@ import {is} from '#validators'; export default function inputAvailabilityCheckMode() { return input({ - validate: is('null', 'empty', 'falsy'), + validate: is('null', 'empty', 'falsy', 'index'), defaultValue: 'null', }); } diff --git a/src/data/composite/control-flow/withResultOfAvailabilityCheck.js b/src/data/composite/control-flow/withResultOfAvailabilityCheck.js index bcbd0b37..a6942014 100644 --- a/src/data/composite/control-flow/withResultOfAvailabilityCheck.js +++ b/src/data/composite/control-flow/withResultOfAvailabilityCheck.js @@ -10,6 +10,7 @@ // * 'falsy': Check that the value isn't false when treated as a boolean // (nor an empty array). Keep in mind this will also be false // for values like zero and the empty string! +// * 'index': Check that the value is a number, and is at least zero. // // See also: // - exitWithoutDependency @@ -57,6 +58,10 @@ export default templateCompositeFrom({ case 'falsy': availability = !!value && (!Array.isArray(value) || !empty(value)); break; + + case 'index': + availability = typeof value === 'number' && value >= 0; + break; } return continuation({'#availability': availability}); |