Browse Source

refactor: changed playlist displayname max length to 64

Kristian Vos 11 months ago
parent
commit
2f9daffb6c

+ 1 - 1
.wiki/Value_Formats.md

@@ -41,7 +41,7 @@ Every input needs validation, below is the required formatting of each value.
 - **Playlist**
   - Display Name
     - Description: Any ASCII character.
-    - Length: From 1 to 32 characters.
+    - Length: From 1 to 64 characters.
     - Regex: ```/^[\x00-\x7F]+$/```
 - **Song**
   - Title

+ 1 - 1
backend/logic/db/index.js

@@ -275,7 +275,7 @@ class _DBModule extends CoreClass {
 					this.schemas.playlist
 						.path("displayName")
 						.validate(
-							displayName => isLength(displayName, 1, 32) && regex.ascii.test(displayName),
+							displayName => isLength(displayName, 1, 64) && regex.ascii.test(displayName),
 							"Invalid display name."
 						);
 

+ 1 - 1
backend/logic/db/schemas/playlist.js

@@ -1,7 +1,7 @@
 import mongoose from "mongoose";
 
 export default {
-	displayName: { type: String, min: 2, max: 32, trim: true, required: true },
+	displayName: { type: String, min: 1, max: 64, trim: true, required: true },
 	songs: [
 		{
 			_id: { type: mongoose.Schema.Types.ObjectId },

+ 2 - 2
frontend/src/components/modals/CreatePlaylist.vue

@@ -25,8 +25,8 @@ const { socket } = useWebsocketsStore();
 const createPlaylist = () => {
 	const { displayName } = playlist.value;
 
-	if (!validation.isLength(displayName, 2, 32))
-		return new Toast("Display name must have between 2 and 32 characters.");
+	if (!validation.isLength(displayName, 1, 64))
+		return new Toast("Display name must have between 1 and 64 characters.");
 	if (!validation.regex.ascii.test(displayName))
 		return new Toast(
 			"Invalid display name format. Only ASCII characters are allowed."

+ 2 - 2
frontend/src/components/modals/EditPlaylist/Tabs/Settings.vue

@@ -47,8 +47,8 @@ const {
 		displayName: {
 			value: playlist.value.displayName,
 			validate: value => {
-				if (!validation.isLength(value, 2, 32))
-					return "Display name must have between 2 and 32 characters.";
+				if (!validation.isLength(value, 1, 64))
+					return "Display name must have between 1 and 64 characters.";
 				if (!validation.regex.ascii.test(value))
 					return "Invalid display name format. Only ASCII characters are allowed.";
 				return true;