Merge branch '15230-fed-collection-crash' refs #15230
[arvados.git] / src / models / vocabulary.ts
index 3dbd4756b22d7f801130e7b80af87ca615019d7f..ea23ad2c79ffc05d56f3e0fa42572a37bc6a38ad 100644 (file)
@@ -2,12 +2,23 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
+import { isObject, has, every } from 'lodash/fp';
+
 export interface Vocabulary {
     strict: boolean;
-    tags: Tag[];
+    tags: Record<string, Tag>;
 }
 
 export interface Tag {
-    strict: boolean;
-    values: string[];
+    strict?: boolean;
+    values?: string[];
 }
+
+const VOCABULARY_VALIDATORS = [
+    isObject,
+    has('strict'),
+    has('tags'),
+];
+
+export const isVocabulary = (value: any) =>
+    every(validator => validator(value), VOCABULARY_VALIDATORS);
\ No newline at end of file