« 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-properties/annotatedReferenceList.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/wiki-properties/annotatedReferenceList.js')
-rw-r--r--src/data/composite/wiki-properties/annotatedReferenceList.js37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/data/composite/wiki-properties/annotatedReferenceList.js b/src/data/composite/wiki-properties/annotatedReferenceList.js
index e8e5ac8c..a5e10c82 100644
--- a/src/data/composite/wiki-properties/annotatedReferenceList.js
+++ b/src/data/composite/wiki-properties/annotatedReferenceList.js
@@ -1,8 +1,15 @@
 import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
-import {validateAnnotatedReferenceList} from '#validators';
 import {combineWikiDataArrays} from '#wiki-data';
 
+import {
+  isContentString,
+  optional,
+  validateArrayItems,
+  validateProperties,
+  validateReference,
+} from '#validators';
+
 import {exposeDependency} from '#composite/control-flow';
 import {inputWikiData, withResolvedAnnotatedReferenceList}
   from '#composite/wiki-data';
@@ -20,16 +27,36 @@ export default templateCompositeFrom({
 
     data: inputWikiData({allowMixedTypes: true}),
     find: input({type: 'function'}),
+
+    reference: input.staticValue({type: 'string', defaultValue: 'reference'}),
+    annotation: input.staticValue({type: 'string', defaultValue: 'annotation'}),
+    thing: input.staticValue({type: 'string', defaultValue: 'thing'}),
   },
 
-  update:
-    referenceListUpdateDescription({
-      validateReferenceList: validateAnnotatedReferenceList,
-    }),
+  update(staticInputs) {
+    const {
+      [input.staticValue('reference')]: referenceProperty,
+      [input.staticValue('annotation')]: annotationProperty,
+    } = staticInputs;
+
+    return referenceListUpdateDescription({
+      validateReferenceList: type =>
+        validateArrayItems(
+          validateProperties({
+            [referenceProperty]: validateReference(type),
+            [annotationProperty]: optional(isContentString),
+          })),
+    })(staticInputs);
+  },
 
   steps: () => [
     withResolvedAnnotatedReferenceList({
       list: input.updateValue(),
+
+      reference: input('reference'),
+      annotation: input('annotation'),
+      thing: input('thing'),
+
       data: input('data'),
       find: input('find'),
     }),