Skip to content

Commit

Permalink
Avoding empty fights
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed May 10, 2024
1 parent aa9a318 commit 931965d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.softwaremagico.kt.core.converters.models.FightConverterRequest;
import com.softwaremagico.kt.core.converters.models.TournamentConverterRequest;
import com.softwaremagico.kt.core.exceptions.TournamentNotFoundException;
import com.softwaremagico.kt.core.exceptions.ValidateBadRequestException;
import com.softwaremagico.kt.core.managers.TeamsOrder;
import com.softwaremagico.kt.core.providers.FightProvider;
import com.softwaremagico.kt.core.providers.GroupProvider;
Expand Down Expand Up @@ -90,6 +91,14 @@ public void addFightsAddedListeners(FightsAddedListener listener) {
fightsAddedListeners.add(listener);
}

@Override
public void validate(FightDTO dto) throws ValidateBadRequestException {
if (dto.getTeam1() == null || dto.getTeam2() == null || dto.getTeam1().getMembers() == null || dto.getTeam2().getMembers() == null
|| dto.getTeam1().getMembers().isEmpty() || dto.getTeam2().getMembers().isEmpty() || dto.getShiaijo() == null || dto.getLevel() == null) {
throw new ValidateBadRequestException(this.getClass(), "Fight '" + dto + "' is malformed.");
}
}

@Override
protected FightConverterRequest createConverterRequest(Fight entity) {
return new FightConverterRequest(entity);
Expand Down

0 comments on commit 931965d

Please sign in to comment.