83 lines
3.5 KiB
C#
83 lines
3.5 KiB
C#
namespace TaxBaik.Application.DTOs;
|
|
|
|
using FluentValidation;
|
|
|
|
public sealed class CreateBlogPostDtoValidator : AbstractValidator<CreateBlogPostDto>
|
|
{
|
|
public CreateBlogPostDtoValidator()
|
|
{
|
|
RuleFor(x => x.Title).NotEmpty().MaximumLength(ValidationRules.TitleMaxLength);
|
|
RuleFor(x => x.Content).NotEmpty().MinimumLength(ValidationRules.MessageMinLength).MaximumLength(ValidationRules.ContentMaxLength);
|
|
RuleFor(x => x.Tags).MaximumLength(ValidationRules.TagsMaxLength);
|
|
RuleFor(x => x.SeoTitle).MaximumLength(ValidationRules.SeoTitleMaxLength);
|
|
RuleFor(x => x.SeoDescription).MaximumLength(ValidationRules.SeoDescriptionMaxLength);
|
|
}
|
|
}
|
|
|
|
public sealed class SubmitInquiryDtoValidator : AbstractValidator<SubmitInquiryDto>
|
|
{
|
|
public SubmitInquiryDtoValidator()
|
|
{
|
|
ApplyInquiryRules(this);
|
|
}
|
|
|
|
internal static void ApplyInquiryRules(AbstractValidator<SubmitInquiryDto> validator) { }
|
|
}
|
|
|
|
public sealed class UpdateInquiryDtoValidator : AbstractValidator<UpdateInquiryDto>
|
|
{
|
|
public UpdateInquiryDtoValidator()
|
|
{
|
|
RuleFor(x => x.Name).NotEmpty().MaximumLength(ValidationRules.NameMaxLength);
|
|
RuleFor(x => x.Phone).NotEmpty().Matches(ValidationRules.KoreanPhonePattern);
|
|
RuleFor(x => x.Email).EmailAddress().When(x => !string.IsNullOrWhiteSpace(x.Email));
|
|
RuleFor(x => x.ServiceType).MaximumLength(ValidationRules.ServiceTypeMaxLength);
|
|
RuleFor(x => x.Message).NotEmpty().MinimumLength(ValidationRules.MessageMinLength).MaximumLength(ValidationRules.MessageMaxLength);
|
|
RuleFor(x => x.Status).NotEmpty();
|
|
RuleFor(x => x.AdminMemo).MaximumLength(ValidationRules.MemoMaxLength);
|
|
}
|
|
}
|
|
|
|
public sealed class CreateClientDtoValidator : AbstractValidator<CreateClientDto>
|
|
{
|
|
public CreateClientDtoValidator()
|
|
{
|
|
RuleFor(x => x.Name).NotEmpty().MaximumLength(ValidationRules.NameMaxLength);
|
|
RuleFor(x => x.CompanyName).MaximumLength(ValidationRules.NameMaxLength);
|
|
RuleFor(x => x.Phone).MaximumLength(ValidationRules.PhoneMaxLength);
|
|
RuleFor(x => x.Email).EmailAddress().When(x => !string.IsNullOrWhiteSpace(x.Email));
|
|
RuleFor(x => x.ServiceType).MaximumLength(ValidationRules.ServiceTypeMaxLength);
|
|
RuleFor(x => x.TaxType).MaximumLength(ValidationRules.ServiceTypeMaxLength);
|
|
RuleFor(x => x.Status).NotEmpty();
|
|
RuleFor(x => x.Source).MaximumLength(ValidationRules.ServiceTypeMaxLength);
|
|
RuleFor(x => x.Memo).MaximumLength(ValidationRules.MemoMaxLength);
|
|
}
|
|
}
|
|
|
|
public sealed class AnnouncementDtoValidator : AbstractValidator<AnnouncementDto>
|
|
{
|
|
public AnnouncementDtoValidator()
|
|
{
|
|
RuleFor(x => x.Title)
|
|
.NotEmpty().WithMessage("제목을 입력하세요.")
|
|
.MaximumLength(ValidationRules.TitleMaxLength).WithMessage("제목은 최대 100자까지 입력 가능합니다.");
|
|
|
|
RuleFor(x => x.Content)
|
|
.MaximumLength(2000).WithMessage("상세 내용은 최대 2000자까지 입력 가능합니다.");
|
|
|
|
RuleFor(x => x.DisplayType)
|
|
.NotEmpty().WithMessage("표시 유형을 선택하세요.")
|
|
.MaximumLength(20).WithMessage("표시 유형은 최대 20자까지 입력 가능합니다.");
|
|
}
|
|
}
|
|
|
|
public sealed class FaqValidator : AbstractValidator<TaxBaik.Domain.Entities.Faq>
|
|
{
|
|
public FaqValidator()
|
|
{
|
|
RuleFor(x => x.Question).NotEmpty().MaximumLength(300);
|
|
RuleFor(x => x.Answer).NotEmpty().MinimumLength(10).MaximumLength(5000);
|
|
RuleFor(x => x.Category).MaximumLength(50);
|
|
}
|
|
}
|