diff --git a/gregui/api/serializers/guest.py b/gregui/api/serializers/guest.py index 6d93031f9e39ca4eff56d0d458f43df7a10a866e..d22c2e1e524ffca684568047c86a939935f52d80 100644 --- a/gregui/api/serializers/guest.py +++ b/gregui/api/serializers/guest.py @@ -61,17 +61,19 @@ class GuestRegisterSerializer(serializers.ModelSerializer): return instance - def validate_date_of_birth(self, value): + def validate_date_of_birth(self, date_of_birth): today = datetime.date.today() # Check that the date of birth is between the interval starting about 100 years ago and last year if ( not today - datetime.timedelta(weeks=100 * 52) - < value - < today - datetime.timedelta(weeks=52) + < date_of_birth + < today - datetime.timedelta(weeks=52) ): raise serializers.ValidationError("Invalid date of birth") + return date_of_birth + class Meta: model = Person fields = (