From 8f4eedd95817059401af2c6eef87f5d3f388d094 Mon Sep 17 00:00:00 2001 From: Arne Dumarey Date: Wed, 17 Jan 2024 08:51:52 +0100 Subject: [PATCH] fix: dont do rename municipality check on nulls --- .../Validators/RenameStreetNameRequestValidator.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/StreetNameRegistry.Api.BackOffice/Validators/RenameStreetNameRequestValidator.cs b/src/StreetNameRegistry.Api.BackOffice/Validators/RenameStreetNameRequestValidator.cs index a55a3720b..86a0936d8 100644 --- a/src/StreetNameRegistry.Api.BackOffice/Validators/RenameStreetNameRequestValidator.cs +++ b/src/StreetNameRegistry.Api.BackOffice/Validators/RenameStreetNameRequestValidator.cs @@ -44,10 +44,12 @@ public RenameStreetNameRequestValidator(BackOfficeContext backOfficeContext) .MunicipalityIdByPersistentLocalId .FindAsync(new object?[] { request.StreetNamePersistentLocalId }, cancellationToken: ct); + // Allow nulls to go through, because otherwise the error message would be incorrect + // It will fail in the next rule / domain anyway return - municipalityIdBySourcePersistentLocalId != null - && municipalityIdByDestinationPersistentLocalId != null - && municipalityIdByDestinationPersistentLocalId.MunicipalityId == municipalityIdBySourcePersistentLocalId.MunicipalityId; + municipalityIdBySourcePersistentLocalId is null + || municipalityIdByDestinationPersistentLocalId is null + || municipalityIdByDestinationPersistentLocalId.MunicipalityId == municipalityIdBySourcePersistentLocalId.MunicipalityId; }) .WithMessage(ValidationErrors.RenameStreetName.SourceAndDestinationStreetNameAreNotInSameMunicipality.Message) .WithErrorCode(ValidationErrors.RenameStreetName.SourceAndDestinationStreetNameAreNotInSameMunicipality.Code)