From 42d586604ea1a6ef5ed5ef364ce0432901749e3c Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 16 Apr 2026 14:50:00 +0200 Subject: [PATCH] Add UpdateObjectProcedureValidator with validation rules Introduced UpdateObjectProcedureValidator using FluentValidation to enforce constraints on UpdateObjectProcedure fields, including ID checks and maximum length restrictions on various properties and nested objects. --- .../UpdateObjectProcedureValidator.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/ReC.Application/Common/Validations/UpdateObjectProcedureValidator.cs diff --git a/src/ReC.Application/Common/Validations/UpdateObjectProcedureValidator.cs b/src/ReC.Application/Common/Validations/UpdateObjectProcedureValidator.cs new file mode 100644 index 0000000..fd02472 --- /dev/null +++ b/src/ReC.Application/Common/Validations/UpdateObjectProcedureValidator.cs @@ -0,0 +1,48 @@ +using FluentValidation; +using ReC.Application.Common.Procedures.UpdateProcedure; + +namespace ReC.Application.Common.Validations; + +public class UpdateObjectProcedureValidator : AbstractValidator +{ + public UpdateObjectProcedureValidator() + { + RuleFor(x => x.Id) + .GreaterThan(0) + .WithMessage("Target GUID/ID must be greater than 0."); + + RuleFor(x => x.ChangedWho) + .MaximumLength(50) + .When(x => x.ChangedWho != null); + + When(x => x.Endpoint is { Description: not null }, () => + { + RuleFor(x => x.Endpoint.Description) + .MaximumLength(250); + }); + + When(x => x.EndpointAuth is { Description: not null }, () => + { + RuleFor(x => x.EndpointAuth.Description) + .MaximumLength(250); + }); + + When(x => x.Profile is { Name: not null }, () => + { + RuleFor(x => x.Profile.Name) + .MaximumLength(50); + }); + + When(x => x.Profile is { Mandantor: not null }, () => + { + RuleFor(x => x.Profile.Mandantor) + .MaximumLength(50); + }); + + When(x => x.Profile is { Description: not null }, () => + { + RuleFor(x => x.Profile.Description) + .MaximumLength(250); + }); + } +}