aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/util.ts
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2024-02-15 23:04:33 +0000
committerLeonardo Bishop <me@leonardobishop.com>2024-02-15 23:04:33 +0000
commit1195b085e31c44bc8fec6817d64063de9022eb66 (patch)
tree6f30cbfbf30acc19347890080cbc907ad094106b /src/lib/util.ts
parent1869b5c5f9565b5e9e20697c4401a2f9ba9f2c3a (diff)
Partially add itemstack support
Diffstat (limited to 'src/lib/util.ts')
-rw-r--r--src/lib/util.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/util.ts b/src/lib/util.ts
index 9903e2c..b8be8cb 100644
--- a/src/lib/util.ts
+++ b/src/lib/util.ts
@@ -1,3 +1,18 @@
-export function stripColourCodes(str: string): string {
- return str.replace(/&[0-9a-fk-or]/i, '');
+const COLOR_CODE_REGEX = /&[0-9a-fk-or]/i;
+const VALID_ID_REGEX = /^[a-z0-9_]+$/i;
+
+export function stripColorCodes(str: string): string {
+ return str.replace(COLOR_CODE_REGEX, '');
+}
+
+export function validateQuestId(id: string): boolean {
+ return VALID_ID_REGEX.test(id);
+}
+
+export function validateCategoryId(id: string): boolean {
+ return VALID_ID_REGEX.test(id);
+}
+
+export function validateTaskId(id: string): boolean {
+ return VALID_ID_REGEX.test(id);
} \ No newline at end of file