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); + }); + } +}