Files
pos-system/services/mission-service-net/src/MissionService.API/Application/Validations/UpdateTaskProgressCommandValidator.cs
Ho Ngoc Hai 59b2cecaf2 feat(P1): add 57 validators + 10 missing handlers across 13 services
Wave 2 — 3 parallel agents fixing P1 issues:

Validators (57 new FluentValidation validators):
- ads-manager: 10 validators for all commands
- ads-billing: 3 validators for all commands
- ads-tracking: 2 validators for missing commands
- ads-analytics: 1 validator for CreateReport
- social: 8 validators for all commands
- mining: 16 validators for all commands
- mission: 4 validators for all commands
- promotion: 13 validators for all commands

Missing handlers (10 implemented):
- promotion: ExchangeVoucher, PurchaseVoucher, SearchVouchers,
  GetCampaignStatistics, GetCampaignVouchers
- mission: GetUserMissionProgress
- mkt-facebook: GetConversations, GetCustomers
- ads-manager: ListAudiences, GetAudienceById

All validators use bilingual messages (EN/VI) and are auto-registered
via MediatR ValidatorBehavior pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 20:24:06 +07:00

43 lines
1.9 KiB
C#

using FluentValidation;
using MissionService.API.Application.Commands;
namespace MissionService.API.Application.Validations;
/// <summary>
/// EN: Validator for UpdateTaskProgressCommand.
/// VI: Validator cho UpdateTaskProgressCommand.
/// </summary>
public class UpdateTaskProgressCommandValidator : AbstractValidator<UpdateTaskProgressCommand>
{
public UpdateTaskProgressCommandValidator()
{
RuleFor(x => x.UserId)
.NotEmpty().WithMessage("User ID is required / ID người dùng là bắt buộc");
RuleFor(x => x.TaskId)
.NotEmpty().WithMessage("Task ID is required / ID task là bắt buộc");
RuleFor(x => x.CurrentValue)
.GreaterThanOrEqualTo(0).WithMessage("Current value must be non-negative / Giá trị hiện tại không được âm");
When(x => x.Evidence != null, () =>
{
RuleFor(x => x.Evidence!.Type)
.NotEmpty().WithMessage("Evidence type is required / Loại bằng chứng là bắt buộc")
.MaximumLength(50).WithMessage("Evidence type max 50 chars / Loại bằng chứng tối đa 50 ký tự");
RuleFor(x => x.Evidence!.Data)
.NotEmpty().WithMessage("Evidence data is required / Dữ liệu bằng chứng là bắt buộc")
.MaximumLength(2000).WithMessage("Evidence data max 2000 chars / Dữ liệu bằng chứng tối đa 2000 ký tự");
RuleFor(x => x.Evidence!.ScreenshotUrl)
.MaximumLength(500).WithMessage("Screenshot URL max 500 chars / URL ảnh chụp tối đa 500 ký tự")
.When(x => x.Evidence!.ScreenshotUrl != null);
RuleFor(x => x.Evidence!.VideoUrl)
.MaximumLength(500).WithMessage("Video URL max 500 chars / URL video tối đa 500 ký tự")
.When(x => x.Evidence!.VideoUrl != null);
});
}
}