Refactor validator to use nested property accessors
Update InsertObjectProcedureValidator to reference nested properties (e.g., x.Action.ProfileId instead of x.ActionProfileId) throughout all entity validation rules. Adjust .When conditions accordingly to match the new data model structure with grouped sub-objects.
This commit is contained in:
@@ -16,11 +16,11 @@ public class InsertObjectProcedureValidator : AbstractValidator<InsertObjectProc
|
|||||||
// ACTION validation
|
// ACTION validation
|
||||||
When(x => x.Entity == "ACTION", () =>
|
When(x => x.Entity == "ACTION", () =>
|
||||||
{
|
{
|
||||||
RuleFor(x => x.ActionProfileId)
|
RuleFor(x => x.Action.ProfileId)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.WithMessage("ACTION requires ActionProfileId (maps to @pACTION_PROFILE_ID).");
|
.WithMessage("ACTION requires ActionProfileId (maps to @pACTION_PROFILE_ID).");
|
||||||
|
|
||||||
RuleFor(x => x.ActionEndpointId)
|
RuleFor(x => x.Action.EndpointId)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.WithMessage("ACTION requires ActionEndpointId (maps to @pACTION_ENDPOINT_ID).");
|
.WithMessage("ACTION requires ActionEndpointId (maps to @pACTION_ENDPOINT_ID).");
|
||||||
});
|
});
|
||||||
@@ -28,7 +28,7 @@ public class InsertObjectProcedureValidator : AbstractValidator<InsertObjectProc
|
|||||||
// ENDPOINT validation
|
// ENDPOINT validation
|
||||||
When(x => x.Entity == "ENDPOINT", () =>
|
When(x => x.Entity == "ENDPOINT", () =>
|
||||||
{
|
{
|
||||||
RuleFor(x => x.EndpointUri)
|
RuleFor(x => x.Endpoint.Uri)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithMessage("ENDPOINT requires EndpointUri (maps to @pENDPOINT_URI).")
|
.WithMessage("ENDPOINT requires EndpointUri (maps to @pENDPOINT_URI).")
|
||||||
.MaximumLength(2000);
|
.MaximumLength(2000);
|
||||||
@@ -37,28 +37,28 @@ public class InsertObjectProcedureValidator : AbstractValidator<InsertObjectProc
|
|||||||
// PROFILE validation
|
// PROFILE validation
|
||||||
When(x => x.Entity == "PROFILE", () =>
|
When(x => x.Entity == "PROFILE", () =>
|
||||||
{
|
{
|
||||||
RuleFor(x => x.ProfileName)
|
RuleFor(x => x.Profile.Name)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithMessage("PROFILE requires ProfileName (maps to @pPROFILE_NAME).")
|
.WithMessage("PROFILE requires ProfileName (maps to @pPROFILE_NAME).")
|
||||||
.MaximumLength(50);
|
.MaximumLength(50);
|
||||||
|
|
||||||
RuleFor(x => x.ProfileMandantor)
|
RuleFor(x => x.Profile.Mandantor)
|
||||||
.MaximumLength(50)
|
.MaximumLength(50)
|
||||||
.When(x => x.ProfileMandantor != null);
|
.When(x => x.Profile.Mandantor != null);
|
||||||
|
|
||||||
RuleFor(x => x.ProfileDescription)
|
RuleFor(x => x.Profile.Description)
|
||||||
.MaximumLength(250)
|
.MaximumLength(250)
|
||||||
.When(x => x.ProfileDescription != null);
|
.When(x => x.Profile.Description != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
// RESULT validation
|
// RESULT validation
|
||||||
When(x => x.Entity == "RESULT", () =>
|
When(x => x.Entity == "RESULT", () =>
|
||||||
{
|
{
|
||||||
RuleFor(x => x.ResultActionId)
|
RuleFor(x => x.Result.ActionId)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.WithMessage("RESULT requires ResultActionId (maps to @pRESULT_ACTION_ID).");
|
.WithMessage("RESULT requires ResultActionId (maps to @pRESULT_ACTION_ID).");
|
||||||
|
|
||||||
RuleFor(x => x.ResultStatusId)
|
RuleFor(x => x.Result.StatusId)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.WithMessage("RESULT requires ResultStatusId (maps to @pRESULT_STATUS_ID).");
|
.WithMessage("RESULT requires ResultStatusId (maps to @pRESULT_STATUS_ID).");
|
||||||
});
|
});
|
||||||
@@ -66,7 +66,7 @@ public class InsertObjectProcedureValidator : AbstractValidator<InsertObjectProc
|
|||||||
// ENDPOINT_PARAMS validation
|
// ENDPOINT_PARAMS validation
|
||||||
When(x => x.Entity == "ENDPOINT_PARAMS", () =>
|
When(x => x.Entity == "ENDPOINT_PARAMS", () =>
|
||||||
{
|
{
|
||||||
RuleFor(x => x.EndpointParamsGroupId)
|
RuleFor(x => x.EndpointParams.GroupId)
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.WithMessage("ENDPOINT_PARAMS requires EndpointParamsGroupId (maps to @pENDPOINT_PARAMS_GROUP_ID).");
|
.WithMessage("ENDPOINT_PARAMS requires EndpointParamsGroupId (maps to @pENDPOINT_PARAMS_GROUP_ID).");
|
||||||
});
|
});
|
||||||
@@ -76,12 +76,12 @@ public class InsertObjectProcedureValidator : AbstractValidator<InsertObjectProc
|
|||||||
.MaximumLength(50)
|
.MaximumLength(50)
|
||||||
.When(x => x.AddedWho != null);
|
.When(x => x.AddedWho != null);
|
||||||
|
|
||||||
RuleFor(x => x.EndpointDescription)
|
RuleFor(x => x.Endpoint.Description)
|
||||||
.MaximumLength(250)
|
.MaximumLength(250)
|
||||||
.When(x => x.EndpointDescription != null);
|
.When(x => x.Endpoint.Description != null);
|
||||||
|
|
||||||
RuleFor(x => x.EndpointAuthDescription)
|
RuleFor(x => x.EndpointAuth.Description)
|
||||||
.MaximumLength(250)
|
.MaximumLength(250)
|
||||||
.When(x => x.EndpointAuthDescription != null);
|
.When(x => x.EndpointAuth.Description != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user