Skip to content

Commit

Permalink
Add validator
Browse files Browse the repository at this point in the history
  • Loading branch information
TawneeOwl committed Oct 10, 2024
1 parent 2a6d32d commit 2dc9d2b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cla_backend/apps/call_centre/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,22 @@ class Meta(EODDetailsSerializerBase.Meta):


class EligibilityCheckSerializer(EligibilityCheckSerializerBase):

def validate_property_set(self,value):
# Iterate through each item (property) in the property_set list
for property_item in value:
if property_item.get('value') is None:
raise serializers.ValidationError("Property 'value' cannot be null.")
if property_item.get('mortgage_left') is None:
raise serializers.ValidationError("Property 'mortgage_left' cannot be null.")
if property_item.get('share') is None:
raise serializers.ValidationError("Property 'share' cannot be null.")
if property_item.get('disputed') is None:
raise serializers.ValidationError("Property 'disputed' cannot be null.")
if property_item.get('main') is None:
raise serializers.ValidationError("Property 'main' cannot be null.")

return value
property_set = PropertySerializer(many=True, required=False)
you = PersonSerializer(required=False, allow_null=True)
partner = PartnerPersonSerializer(required=False, allow_null=True)
Expand Down

0 comments on commit 2dc9d2b

Please sign in to comment.