Skip to content
Snippets Groups Projects
Commit 1f8787c9 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-113: Fixing wrong implementation of validate method

parent 2df393b1
No related branches found
No related tags found
1 merge request!166GREG-113 guest date of birth
......@@ -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 = (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment