Add InsertResultCommandValidator with validation rules

Introduce InsertResultCommandValidator using FluentValidation to enforce required and value constraints on ActionId and References.BatchId properties, including custom error messages.
This commit is contained in:
2026-04-16 14:38:45 +02:00
parent 0a564d8aa8
commit 0d9489203f

View File

@@ -0,0 +1,21 @@
using FluentValidation;
using ReC.Application.Results.Commands;
namespace ReC.Application.Common.Validations;
public class InsertResultCommandValidator : AbstractValidator<InsertResultCommand>
{
public InsertResultCommandValidator()
{
RuleFor(x => x.ActionId)
.NotNull()
.WithMessage("ActionId is required.")
.GreaterThan(0L)
.When(x => x.ActionId.HasValue)
.WithMessage("ActionId must be greater than 0.");
RuleFor(x => x.References.BatchId)
.NotEmpty()
.WithMessage("BatchId is required.");
}
}