121291eeed
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
Allow optional slug on create/update, generate from title with unique fallback, so BackOffice can publish posts without manual slug entry. Co-authored-by: Cursor <cursoragent@cursor.com>
24 lines
1.1 KiB
C#
24 lines
1.1 KiB
C#
using FluentValidation;
|
|
|
|
namespace CMSMicroservice.Application.BlogPostCQ.Commands.UpdateBlogPost;
|
|
|
|
public class UpdateBlogPostCommandValidator : AbstractValidator<UpdateBlogPostCommand>
|
|
{
|
|
public UpdateBlogPostCommandValidator()
|
|
{
|
|
RuleFor(x => x.Id).GreaterThan(0).WithMessage("شناسه مقاله نامعتبر است");
|
|
|
|
RuleFor(x => x.Title)
|
|
.NotEmpty().WithMessage("عنوان مقاله الزامی است")
|
|
.MaximumLength(200).WithMessage("عنوان نمیتواند بیشتر از 200 کاراکتر باشد");
|
|
|
|
RuleFor(x => x.Slug)
|
|
.MaximumLength(200).WithMessage("نشانی نمیتواند بیشتر از 200 کاراکتر باشد")
|
|
.Matches(@"^[a-z0-9\-]+$").WithMessage("نشانی فقط میتواند شامل حروف کوچک انگلیسی، اعداد و خط تیره باشد")
|
|
.When(x => !string.IsNullOrWhiteSpace(x.Slug));
|
|
|
|
RuleFor(x => x.HtmlContent)
|
|
.NotEmpty().WithMessage("محتوای مقاله الزامی است");
|
|
}
|
|
}
|