diff --git a/src/ReC.Application/Common/Validations/ReadResultViewQueryValidator.cs b/src/ReC.Application/Common/Validations/ReadResultViewQueryValidator.cs new file mode 100644 index 0000000..1faef60 --- /dev/null +++ b/src/ReC.Application/Common/Validations/ReadResultViewQueryValidator.cs @@ -0,0 +1,34 @@ +using FluentValidation; +using ReC.Application.Results.Queries; + +namespace ReC.Application.Common.Validations; + +public class ReadResultViewQueryValidator : AbstractValidator +{ + public ReadResultViewQueryValidator() + { + RuleFor(x => x) + .Must(x => x.Id.HasValue || x.ActionId.HasValue || x.ProfileId.HasValue || x.BatchId is not null) + .WithMessage("At least one filter (Id, ActionId, ProfileId or BatchId) must be provided."); + + RuleFor(x => x.Id) + .GreaterThan(0) + .When(x => x.Id.HasValue) + .WithMessage("Id must be greater than 0."); + + RuleFor(x => x.ActionId) + .GreaterThan(0) + .When(x => x.ActionId.HasValue) + .WithMessage("ActionId must be greater than 0."); + + RuleFor(x => x.ProfileId) + .GreaterThan(0) + .When(x => x.ProfileId.HasValue) + .WithMessage("ProfileId must be greater than 0."); + + RuleFor(x => x.BatchId) + .NotEmpty() + .When(x => x.BatchId is not null) + .WithMessage("BatchId must not be empty when provided."); + } +}