24 lines
819 B
C#
24 lines
819 B
C#
using FluentValidation;
|
|
using TakeoutSaaS.Application.App.Deliveries.Commands;
|
|
|
|
namespace TakeoutSaaS.Application.App.Deliveries.Validators;
|
|
|
|
/// <summary>
|
|
/// 创建配送单命令验证器。
|
|
/// </summary>
|
|
public sealed class CreateDeliveryOrderCommandValidator : AbstractValidator<CreateDeliveryOrderCommand>
|
|
{
|
|
/// <summary>
|
|
/// 初始化验证规则。
|
|
/// </summary>
|
|
public CreateDeliveryOrderCommandValidator()
|
|
{
|
|
RuleFor(x => x.OrderId).GreaterThan(0);
|
|
RuleFor(x => x.ProviderOrderId).MaximumLength(64);
|
|
RuleFor(x => x.CourierName).MaximumLength(64);
|
|
RuleFor(x => x.CourierPhone).MaximumLength(32);
|
|
RuleFor(x => x.FailureReason).MaximumLength(256);
|
|
RuleFor(x => x.DeliveryFee).GreaterThanOrEqualTo(0).When(x => x.DeliveryFee.HasValue);
|
|
}
|
|
}
|