« get me outta code hell

data, test: ArtTag.nameShort - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-09 19:04:04 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-09 19:04:04 -0300
commit14329ec8eedb7ad5dcb6a3308a26686bd381ab36 (patch)
tree15775ee8a22271d420b8899dd8daffb0b0dbcaf4 /src/data/things
parentb06c194fc02da22564bcb165db33282f411859a3 (diff)
data, test: ArtTag.nameShort
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/art-tag.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js
index 3d65b578..7e466555 100644
--- a/src/data/things/art-tag.js
+++ b/src/data/things/art-tag.js
@@ -1,4 +1,6 @@
+import {exposeUpdateValueOrContinue} from '#composite';
 import {sortAlbumsTracksChronologically} from '#wiki-data';
+import {isName} from '#validators';
 
 import Thing, {
   color,
@@ -19,15 +21,20 @@ export class ArtTag extends Thing {
     color: color(),
     isContentWarning: flag(false),
 
-    nameShort: {
-      flags: {update: true, expose: true},
+    nameShort: [
+      exposeUpdateValueOrContinue(),
 
-      expose: {
+      {
         dependencies: ['name'],
-        transform: (value, {name}) =>
-          value ?? name.replace(/ \(.*?\)$/, ''),
+        compute: ({name}) =>
+          name.replace(/ \([^)]*?\)$/, ''),
       },
-    },
+
+      {
+        flags: {update: true, expose: true},
+        validate: {isName},
+      },
+    ],
 
     // Update only