Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14503_keep_services
[arvados-workbench2.git] / src / models / vocabulary.ts
diff --git a/src/models/vocabulary.ts b/src/models/vocabulary.ts
new file mode 100644 (file)
index 0000000..ea23ad2
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { isObject, has, every } from 'lodash/fp';
+
+export interface Vocabulary {
+    strict: boolean;
+    tags: Record<string, Tag>;
+}
+
+export interface Tag {
+    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