Add FluentValidation to application services
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m45s
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m45s
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user