diff --git a/backend/serializers/participant_serializer.py b/backend/serializers/participant_serializer.py index beb4dc42..1c866d90 100644 --- a/backend/serializers/participant_serializer.py +++ b/backend/serializers/participant_serializer.py @@ -31,7 +31,8 @@ class Meta: validate=[ validate.Length(max=13), validate.Regexp("^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$"), - ] + ], + allow_none=True, ) slack = fields.Str( validate=[validate.Length(max=21), validate.Regexp("^[a-z0-9][a-z0-9._-]*$")] diff --git a/backend/tests/test_participants_list.py b/backend/tests/test_participants_list.py index 273617a5..de8fb86e 100644 --- a/backend/tests/test_participants_list.py +++ b/backend/tests/test_participants_list.py @@ -45,6 +45,15 @@ def test_create_participant_when_logged_in(app, auth_client, new_participant): assert value in response +def test_create_participant_wiht_none_as_phone(auth_client, new_participant): + new_participant["phone"] = None + + rv = auth_client.post("/participants/", json=new_participant) + response = rv.get_json() + assert rv.status_code == HTTPStatus.CREATED + assert response["phone"] is None + + def test_try_create_participant_without_payload(auth_client): """Test try to create new participant without payload.""" rv = auth_client.post("/participants/", json={})