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>
26 lines
1.2 KiB
C#
26 lines
1.2 KiB
C#
using FluentValidation;
|
|
|
|
namespace CMSMicroservice.Application.BlogPostCQ.Commands.CreateBlogPost;
|
|
|
|
public class CreateBlogPostCommandValidator : AbstractValidator<CreateBlogPostCommand>
|
|
{
|
|
public CreateBlogPostCommandValidator()
|
|
{
|
|
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.Summary)
|
|
.MaximumLength(500).WithMessage("خلاصه نمیتواند بیشتر از 500 کاراکتر باشد")
|
|
.When(x => !string.IsNullOrEmpty(x.Summary));
|
|
|
|
RuleFor(x => x.HtmlContent)
|
|
.NotEmpty().WithMessage("محتوای مقاله الزامی است");
|
|
}
|
|
}
|