From a420c51b4744c87df026fc00d6c5200690df9ff8 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Mon, 5 Jan 2026 22:57:09 +0330 Subject: [PATCH] fix: Add null check for Description field in Create and Update Discount Category command validators --- .../CreateDiscountCategoryCommandValidator.cs | 3 ++- .../UpdateDiscountCategoryCommandValidator.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs b/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs index 544c071..7909a42 100644 --- a/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs +++ b/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/CreateDiscountCategory/CreateDiscountCategoryCommandValidator.cs @@ -14,6 +14,7 @@ public class CreateDiscountCategoryCommandValidator : AbstractValidator x.Description) - .MaximumLength(1000).WithMessage("توضیحات نباید بیشتر از 1000 کاراکتر باشد"); + .MaximumLength(1000).WithMessage("توضیحات نباید بیشتر از 1000 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.Description)); } } diff --git a/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs b/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs index 4b57a41..103eedb 100644 --- a/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs +++ b/src/BackOffice.BFF.Application/DiscountCategoryCQ/Commands/UpdateDiscountCategory/UpdateDiscountCategoryCommandValidator.cs @@ -17,7 +17,8 @@ public class UpdateDiscountCategoryCommandValidator : AbstractValidator x.Description) - .MaximumLength(1000).WithMessage("توضیحات نباید بیشتر از 1000 کاراکتر باشد"); + .MaximumLength(1000).WithMessage("توضیحات نباید بیشتر از 1000 کاراکتر باشد") + .When(x => !string.IsNullOrEmpty(x.Description)); RuleFor(x => x.ParentCategoryId) .NotEqual(x => x.CategoryId).When(x => x.ParentCategoryId.HasValue)