Skip to content

Commit

Permalink
[#233] Update5
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Dec 20, 2024
1 parent 4104ac7 commit 1c9e1b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
17 changes: 7 additions & 10 deletions src/openklant/components/klantinteracties/models/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
code_soort_object_id: str,
object_id: str,
):
"""Init fields"""
self.code_register = code_register
self.code_objecttype = code_objecttype
self.code_soort_object_id = code_soort_object_id
Expand Down Expand Up @@ -95,7 +96,7 @@ def validate_code_soort_object_id(self) -> None:
)

def validate_object_id(self) -> None:
"""Validates the object ID based on the codeSoortObjectId"""
"""Validates the object_id based on the codeSoortObjectId"""
if not self.object_id:
return

Expand All @@ -109,15 +110,11 @@ def validate_object_id(self) -> None:
validator()
else:
raise serializers.ValidationError(
{
"partijIdentificator.objectId": _(
"Ongeldige Partij Identificator codeSoortObjectId."
)
}
{"partijIdentificator.objectId": _("Ongeldige codeSoortObjectId.")}
)

def _validate_bsn(self) -> None:
"""Validates the BSN Object ID length"""
"""Validates the bsn object_id"""
if len(self.object_id) not in [8, 9]:
raise serializers.ValidationError(
{
Expand All @@ -128,7 +125,7 @@ def _validate_bsn(self) -> None:
)

def _validate_vestigingsnummer(self) -> None:
"""Validates the VestigingsNummer Object ID length"""
"""Validates the vestigingsNummer object_id"""
if len(self.object_id) not in [12]:
raise serializers.ValidationError(
{
Expand All @@ -139,7 +136,7 @@ def _validate_vestigingsnummer(self) -> None:
)

def _validate_rsin(self) -> None:
"""Validates the Rsin Object ID length"""
"""Validates the rsin object_id"""
if len(self.object_id) not in [8, 9]:
raise serializers.ValidationError(
{
Expand All @@ -150,7 +147,7 @@ def _validate_rsin(self) -> None:
)

def _validate_kvknummer(self) -> None:
"""Validates the KvkNummer Object ID length"""
"""Validates the kvkNummer object_id"""
if len(self.object_id) not in [8]:
raise serializers.ValidationError(
{
Expand Down
14 changes: 3 additions & 11 deletions src/openklant/components/klantinteracties/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
)


partij_identificator = {
"code_objecttype": "natuurlijk_persoon",
"code_soort_object_id": "bsn",
"object_id": "12345678",
"code_register": "brp",
}


class PartijIdentificatorValidatorTests(TestCase):
def test_valid(self):
data = {
Expand All @@ -26,7 +18,7 @@ def test_valid(self):
validator = PartijIdentificatorValidator(**data)
validator.validate()

# Start validate_code_objecttype section
# Start section validate_code_objecttype

def test_valid_empty_code_objecttype(self):
data = {
Expand Down Expand Up @@ -78,7 +70,7 @@ def test_code_objecttype_not_found_in_code_register(self):
details["partijIdentificator.codeObjecttype"]["code"], "invalid"
)

# Start validate_code_soort_object_id section
# Start section validate_code_soort_object_id

def test_valid_empty_code_soort_object_id(self):
data = {
Expand Down Expand Up @@ -130,7 +122,7 @@ def test_code_soort_object_id_not_found_in_code_objecttype(self):
details["partijIdentificator.codeSoortObjectId"]["code"], "invalid"
)

# Start validate_object_id section
# Start section validate_object_id

def test_valid_empty_object_id(self):
data = {
Expand Down

0 comments on commit 1c9e1b9

Please sign in to comment.