From 0d9489203f647b97a0a090fda91846e51a759a8c Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 16 Apr 2026 14:38:45 +0200 Subject: [PATCH] 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. --- .../InsertResultCommandValidator.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/ReC.Application/Common/Validations/InsertResultCommandValidator.cs diff --git a/src/ReC.Application/Common/Validations/InsertResultCommandValidator.cs b/src/ReC.Application/Common/Validations/InsertResultCommandValidator.cs new file mode 100644 index 0000000..5403e15 --- /dev/null +++ b/src/ReC.Application/Common/Validations/InsertResultCommandValidator.cs @@ -0,0 +1,21 @@ +using FluentValidation; +using ReC.Application.Results.Commands; + +namespace ReC.Application.Common.Validations; + +public class InsertResultCommandValidator : AbstractValidator +{ + 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."); + } +}