diff --git a/src/openklant/components/klantinteracties/api/tests/test_partijen.py b/src/openklant/components/klantinteracties/api/tests/test_partijen.py index 9e8cbf7d..28ae51eb 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_partijen.py +++ b/src/openklant/components/klantinteracties/api/tests/test_partijen.py @@ -2118,7 +2118,7 @@ def test_invalid_validation_partij_identificator_code_objecttype(self): } # ValidationError, "ObjectType keuzes zijn beperkt op basis van CodeRegister." - with self.assertRaises(ValidationError): + with self.assertRaises(ValidationError) as error: self.client.post(url, data) def test_invalid_validation_partij_identificator_code_soort_object_id(self): @@ -2135,7 +2135,7 @@ def test_invalid_validation_partij_identificator_code_soort_object_id(self): }, } # "CodeSoortObjectId keuzes zijn beperkt op basis van CodeObjectType.", - with self.assertRaises(ValidationError): + with self.assertRaises(ValidationError) as error: self.client.post(url, data) def test_invalid_validation_partij_identificator_object_id(self): @@ -2152,7 +2152,7 @@ def test_invalid_validation_partij_identificator_object_id(self): }, } # "De lengte van de ObjectId moet tussen 8 en 9 liggen." - with self.assertRaises(ValidationError): + with self.assertRaises(ValidationError) as error: self.client.post(url, data) def test_valid_validation_partij_identificator(self): diff --git a/src/openklant/components/klantinteracties/models/validators.py b/src/openklant/components/klantinteracties/models/validators.py index 9866b7f7..cbc55b17 100644 --- a/src/openklant/components/klantinteracties/models/validators.py +++ b/src/openklant/components/klantinteracties/models/validators.py @@ -56,7 +56,9 @@ def validate_code_object_type(self) -> None: return if self.code_object_type not in self.REGISTERS.get(self.code_register, {}): - raise ValidationError("ERRORE") + raise ValidationError( + _("ObjectType keuzes zijn beperkt op basis van CodeRegister.") + ) def validate_code_soort_object_id(self) -> None: """Validates the CodeSoortObjectId based on register and CodeObjectType""" @@ -73,7 +75,9 @@ def validate_code_soort_object_id(self) -> None: self.code_soort_object_id in d.get(self.code_object_type, []) for d in self.REGISTERS.values() ): - raise ValidationError("ERRORE") + raise ValidationError( + _("CodeSoortObjectId keuzes zijn beperkt op basis van CodeObjectType.") + ) def validate_object_id(self) -> None: """Validates the object ID based on the SoortObjectId""" @@ -91,24 +95,35 @@ def validate_object_id(self) -> None: if validator: validator() else: - raise ValidationError("ERRORE") + raise ValidationError( + code="object_id", + message=(_("Ongeldige Partij Identificator CodeSoortObjectId.")), + ) def _validate_bsn(self) -> None: """Validates the BSN Object ID length""" if len(self.object_id) not in [8, 9]: - raise ValidationError("ERRORE") + raise ValidationError( + {"object_id": "De lengte van de ObjectId moet tussen 8 en 9 liggen."} + ) def _validate_vestigingsnummer(self) -> None: """Validates the VestigingsNummer Object ID length""" if len(self.object_id) not in [12]: - raise ValidationError("ERRORE") + raise ValidationError( + {"object_id": _("De lengte van de ObjectId moet 12 tekens zijn.")} + ) def _validate_rsin(self) -> None: """Validates the Rsin Object ID length""" if len(self.object_id) not in [8, 9]: - raise ValidationError("ERRORE") + raise ValidationError( + {"object_id": _("De lengte van de ObjectId moet tussen 8 en 9 liggen.")} + ) def _validate_kvknummer(self) -> None: """Validates the KvkNummer Object ID length""" if len(self.object_id) not in [8]: - raise ValidationError("ERRORE") + raise ValidationError( + {"object_id": _("De lengte van de ObjectId moet 8 tekens zijn.")} + )