using FluentValidation; using MissionService.API.Application.Commands; namespace MissionService.API.Application.Validations; /// /// EN: Validator for UpdateTaskProgressCommand. /// VI: Validator cho UpdateTaskProgressCommand. /// public class UpdateTaskProgressCommandValidator : AbstractValidator { 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); }); } }