« get me outta code hell

inputSoupyFind.js « wiki-data « composite « data « src - 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
blob: 4ae7bd3b1882c398fa8bfa335ce341793d7002a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
}