From 6a3ce847d6c9fa05bc77d1e6c65cbda35d9e7be3 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 29 Aug 2022 03:18:43 +0000 Subject: [PATCH] Make sure number of membership months is entered. --- apiserver/apiserver/api/serializers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index e77d648..8facdaa 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -93,6 +93,9 @@ class TransactionSerializer(serializers.ModelSerializer): if validated_data['category'] != 'Membership': validated_data['number_of_membership_months'] = 0 + if validated_data['category'] == 'Membership' and not validated_data['number_of_membership_months']: + raise ValidationError(dict(number_of_membership_months='This field is required.')) + if validated_data['account_type'] == 'Protocoin' and validated_data['category'] == 'Exchange': raise ValidationError(dict(category='Can\'t purchase Protocoin with Protocoin.'))