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:
@@ -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.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user