Skip to content

Commit

Permalink
[Fix #156] Remove unique name validation constraint for FaultEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
kostobog committed Sep 13, 2024
1 parent 0ed6cf2 commit 261d0f9
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ protected BaseDao<FaultEvent> getPrimaryDao() {
}

protected void customValidation(Object target, Errors errors, Object... validationHints ){
super.customValidation(target, errors, validationHints);
ConstraintGroupsAdapter groups = new ConstraintGroupsAdapter(validationHints);
FaultEvent instance = (FaultEvent) target;

if(groups.isCreateGroup() && exists(instance)){
errors.rejectValue("uri", "uri.exists", "The uri should be null or unique");
}
if(groups.isUpdateGroup() && !exists(instance)){
errors.rejectValue("uri", "uri.not-exists", "Uri does not refer to an existing entity");
}

if (instance.getEventType() == FtaEventType.INTERMEDIATE && (instance.getGateType() == null || instance.getGateType() == GateType.UNUSED)) {
errors.rejectValue("gateType", "gateType.invalid");
}
Expand Down

0 comments on commit 261d0f9

Please sign in to comment.