aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/materials.ts3
-rw-r--r--src/lib/util.ts19
2 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/materials.ts b/src/lib/materials.ts
new file mode 100644
index 0000000..36c5aee
--- /dev/null
+++ b/src/lib/materials.ts
@@ -0,0 +1,3 @@
+import materials from '@/data/materials.json';
+
+export default materials; \ No newline at end of file
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