From 7aa53504842c010719a6007790558f294ca079d2 Mon Sep 17 00:00:00 2001 From: XShine555 Date: Mon, 6 Jul 2026 02:20:47 +0200 Subject: [PATCH] fix(playlists): reject empty/whitespace name and description on update --- .../Validators/PlayLists/UpdatePlayListRequestValidator.cs | 2 ++ backend/Musify.Application/PlayLists/UpdatePlayList.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/Musify.Api/Validators/PlayLists/UpdatePlayListRequestValidator.cs b/backend/Musify.Api/Validators/PlayLists/UpdatePlayListRequestValidator.cs index defc147..7d35d9b 100644 --- a/backend/Musify.Api/Validators/PlayLists/UpdatePlayListRequestValidator.cs +++ b/backend/Musify.Api/Validators/PlayLists/UpdatePlayListRequestValidator.cs @@ -8,10 +8,12 @@ public sealed class UpdatePlayListRequestValidator : AbstractValidator x.NewName) + .NotEmpty() .MaximumLength(50) .When(x => x.NewName is not null); RuleFor(x => x.NewDescription) + .NotEmpty() .MaximumLength(256) .When(x => x.NewDescription is not null); } diff --git a/backend/Musify.Application/PlayLists/UpdatePlayList.cs b/backend/Musify.Application/PlayLists/UpdatePlayList.cs index 40f2440..5586d3d 100644 --- a/backend/Musify.Application/PlayLists/UpdatePlayList.cs +++ b/backend/Musify.Application/PlayLists/UpdatePlayList.cs @@ -45,13 +45,13 @@ namespace Musify.Application.PlayLists return Error.Unauthorized(); } - if (request.NewName is not null) + if (!string.IsNullOrWhiteSpace(request.NewName)) { playListEntity.Name = request.NewName; playListEntity.NormalizedName = request.NewName.Trim().ToUpperInvariant(); } - if (request.NewDescription is not null) + if (!string.IsNullOrWhiteSpace(request.NewDescription)) { playListEntity.Description = request.NewDescription; }