« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-data/inputSoupyFind.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/wiki-data/inputSoupyFind.js')
-rw-r--r--src/data/composite/wiki-data/inputSoupyFind.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/data/composite/wiki-data/inputSoupyFind.js b/src/data/composite/wiki-data/inputSoupyFind.js
new file mode 100644
index 00000000..4ae7bd3b
--- /dev/null
+++ b/src/data/composite/wiki-data/inputSoupyFind.js
@@ -0,0 +1,22 @@
+import {input} from '#composite';
+import {anyOf, isFunction, isString} from '#validators';
+
+export default () =>
+  input({
+    validate:
+      anyOf(
+        isFunction,
+        val => {
+          isString(val);
+
+          if (!val.startsWith('_soupyFind:')) {
+            throw new Error(`Expected soupyFind.input() token`);
+          }
+
+          return true;
+        }),
+  });
+
+export function getSoupyFindInputKey(value) {
+  return value.slice('_soupyFind:'.length);
+}