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.
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Validations;
|
||||||
|
|
||||||
|
public class UpdateObjectProcedureValidator : AbstractValidator<UpdateObjectProcedure>
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user